This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"github.com/gorilla/mux" | |
"github.com/johan-lejdung/go-microservice-middleware-guide/mw" | |
"github.com/urfave/negroni" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"github.com/gorilla/mux" | |
"github.com/urfave/negroni" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mw | |
import ( | |
"fmt" | |
"net/http" | |
"time" | |
) | |
type Logger struct{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
firstMiddleware(secondMiddleware(lastHandler)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Middleware { | |
ServeHTTP(ResponseWriter, *Request, *Handler) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
go test -v -race -coverprofile=coverage.out -covermode=atomic ./... | |
bash <(curl -s https://codecov.io/bash) |