Closed kmulvey closed 9 years ago
I setup a middleware solution in the most recent commit fool
if you think of middleware as just a wrapper, that's what it is.
i know, im just concerned that creating that function on each request will use an undue amount of memory.
from vishal: https://github.com/codegangsta/negroni
actually there are a bunch of good articles on this blog https://elithrar.github.io/ although i don't fully understand all of it yet.
cool, looks like I have some homework.. However, middleware is a function call really under the hood..
link overload
im trying to convert you middleware to the following format but failing:
package moose
import ( "log" "net/http" )
type Middleware struct { moose bool }
// Middleware is a struct that has a ServeHTTP method func NewMiddleware() *Middleware { return &Middleware{true} }
// The middleware handler func (l Middleware) ServeHTTP(w http.ResponseWriter, req http.Request, next http.HandlerFunc) { // Log moose status log.Printf("MOOSE: %v\n", l.moose)
// Call the next middleware handler
next(w, req)
}
this is the best one ive seen so far https://github.com/gin-gonic/gin
i cant figure out how to write a session middle ware though ... i dont think its the lib's fault, im just an idiot
gin looks pretty fast to me
INFO[0003] started handling request method=GET remote=127.0.0.1:48301 request=/ INFO[0003] completed handling request proto=HTTP/1.1 status=200 took=38.203us INFO[0003] started handling request method=GET remote=127.0.0.1:48302 request=/ INFO[0003] completed handling request proto=HTTP/1.1 status=200 took=39.531us INFO[0003] started handling request method=GET remote=127.0.0.1:48303 request=/ INFO[0003] completed handling request proto=HTTP/1.1 status=200 took=40.229us INFO[0003] started handling request method=GET remote=127.0.0.1:48304 request=/ INFO[0003] completed handling request proto=HTTP/1.1 status=200 took=39.95us INFO[0003] started handling request method=GET remote=127.0.0.1:48305 request=/
chose gin ... see #21
logie found something i mentioned to Vishal in that I dont think mux really supports middleware (at least in the form we are used to). We should talk about options:
https://github.com/pilu/traffic https://github.com/gocraft/web https://github.com/gorilla/mux https://github.com/codegangsta/martini https://github.com/rcrowley/go-tigertonic
maybe others?