logie17 / Project-V

The future of telepresence
0 stars 1 forks source link

talk about router #18

Closed kmulvey closed 9 years ago

kmulvey commented 9 years ago

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?

logie17 commented 9 years ago

I setup a middleware solution in the most recent commit fool

logie17 commented 9 years ago

if you think of middleware as just a wrapper, that's what it is.

kmulvey commented 9 years ago

i know, im just concerned that creating that function on each request will use an undue amount of memory.

kmulvey commented 9 years ago

from vishal: https://github.com/codegangsta/negroni

kmulvey commented 9 years ago

https://elithrar.github.io/article/map-string-interface/

kmulvey commented 9 years ago

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.

logie17 commented 9 years ago

cool, looks like I have some homework.. However, middleware is a function call really under the hood..

kmulvey commented 9 years ago

https://medium.com/@benbjohnson/structuring-applications-in-go-3b04be4ff091 https://elithrar.github.io/

kmulvey commented 9 years ago

https://goji.io/

kmulvey commented 9 years ago

https://goji.io/

logie17 commented 9 years ago

link overload

kmulvey commented 9 years ago

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)

}

kmulvey commented 9 years ago

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

kmulvey commented 9 years ago

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=/

kmulvey commented 9 years ago

chose gin ... see #21