Golang Middleware

Handlers responsible for writing headers and bodies into HTTP responses

    // ServerHTTP should write reply headers and data
    // to the ResponseWriter and then return
    type Handler interface {
        ServerHTTP(Responsewriter, *Request)

Pattern for writing HTTP Middleware

    func middlewareHandler(next http.Handler) http.Handler{
        return http.HandlerFunc(func(w http.Responsewriter, r *http.Request){
            // Our middleware logic goes here before
            // executing  application handler
            next.ServeHTTP(w, r)
            // Our middleware logic goes here after
            // executing application handler

Writing HTTP middleware with Negroni

    func MyMiddleware(w http.ResponseWriter, r *http.Reques, next http.HandlerFunc){
        // Logic before executing the next handler
        next(w, r)
        // Logic after executing the next handler

Mapping Middleware Chaining with Negroni

    func main(){
        mux := http.NewServerMux()
        n := negroni.New()
        server := &http.Server {
            Addr : ":8080",
            Handler : n

Middleware Explained https://www.youtube.com/watch?v=jW31hG6K7jQ

Middleware in Go https://lanreadelowo.com/blog/2017/04/25/go-middleware/

Simple HTTP middleware with Go https://hackernoon.com/simple-http-middleware-with-go-79a4ad62889b

Passwordless Authentication With Golang http://www.pixeldonor.com/2015/feb/09/passwordless-authentication-golang/

Http Middleware: GOLANG https://www.linkedin.com/pulse/http-middleware-golang-ramarson-r/