Skip to content

Instantly share code, notes, and snippets.

View johan-lejdung's full-sized avatar
💻
Coding Stuff

Johan Lejdung johan-lejdung

💻
Coding Stuff
View GitHub Profile
package main
import (
"fmt"
"net/http"
"github.com/gorilla/mux"
"github.com/johan-lejdung/go-microservice-middleware-guide/mw"
"github.com/urfave/negroni"
)
package main
import (
"fmt"
"net/http"
"github.com/gorilla/mux"
"github.com/urfave/negroni"
)
package mw
import (
"fmt"
"net/http"
"time"
)
type Logger struct{}
firstMiddleware(secondMiddleware(lastHandler))
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)
})
}
interface Middleware {
ServeHTTP(ResponseWriter, *Request, *Handler)
}
// 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) {
go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
bash <(curl -s https://codecov.io/bash)