initial commit

This commit is contained in:
2017-11-10 06:54:12 +00:00
commit a189881568
6 changed files with 201 additions and 0 deletions

24
route.go Normal file
View File

@@ -0,0 +1,24 @@
package tuu
import (
"net/http"
gcontext "github.com/gorilla/context"
)
type Route struct {
Method string
Path string
Handler Handler
}
func (r *Route) ServeHTTP(res http.ResponseWriter, req *http.Request) {
defer gcontext.Clear(req)
c := NewContext(*r, res, req)
if err := r.Handler(c); err != nil {
c.Response().WriteHeader(500)
c.Response().Write([]byte(err.Error()))
}
}