Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Coding Stuff ⌨️

Johan Lejdung johan-lejdung

💭
Coding Stuff ⌨️
View GitHub Profile
View middleware_main_v2.go
package main
import (
"fmt"
"net/http"
"github.com/gorilla/mux"
"github.com/johan-lejdung/go-microservice-middleware-guide/mw"
"github.com/urfave/negroni"
)
View middleware_main_v1.go
package main
import (
"fmt"
"net/http"
"github.com/gorilla/mux"
"github.com/urfave/negroni"
)
View middleware_logger.go
package mw
import (
"fmt"
"net/http"
"time"
)
type Logger struct{}
View middelware_impl2.go
firstMiddleware(secondMiddleware(lastHandler))
View middelware_impl1.go
func middleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Code for the middleware...
next.ServeHTTP(w, r)
})
}
View middelware_interface.go
interface Middleware {
ServeHTTP(ResponseWriter, *Request, *Handler)
}
View SendGrid-send-email–template.go
// A representation of how the EmailTemplate struct looks like. The one used below is genereted with ProtoBuf
type EmailTemplate struct {
Email string
Params map[string]string
Template EmailTemplate_TemplateType // An enum that contains the different templates
}
// Send will send a email to the user with instructions to reset their password
// Returns if it's successfull or not
func (c *EmailTemplateClient) Send(emailTemplate *emailservice.EmailTemplate) (bool, error) {
View codecov_exmpl.sh
go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
bash <(curl -s https://codecov.io/bash)