mirror of
https://github.com/cubixle/tuu.git
synced 2026-04-25 00:34:43 +01:00
32 lines
513 B
Go
32 lines
513 B
Go
package tuu
|
|
|
|
import (
|
|
"github.com/gorilla/mux"
|
|
"net/http"
|
|
|
|
gcontext "github.com/gorilla/context"
|
|
)
|
|
|
|
type Route struct {
|
|
Method string
|
|
Path string
|
|
Handler Handler
|
|
MuxHandler mux.Route
|
|
}
|
|
|
|
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()))
|
|
}
|
|
}
|
|
|
|
type StaticRoute struct {
|
|
Path string
|
|
Handler http.Handler
|
|
}
|