mirror of
https://github.com/cubixle/tuu.git
synced 2026-04-24 21:24:43 +01:00
initial commit
This commit is contained in:
24
route.go
Normal file
24
route.go
Normal 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()))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user