kos/entry/http/types.go

27 lines
478 B
Go
Raw Normal View History

2023-04-23 17:57:36 +08:00
package http
import "net/http"
type responsePayload struct {
Code int `json:"code"`
Reason string `json:"reason,omitempty"`
Data any `json:"data,omitempty"`
}
type HandleFunc func(ctx *Context) (err error)
type Middleware func(next HandleFunc) HandleFunc
type Route struct {
Method string
Path string
Handle HandleFunc
}
func Wrap(f http.HandlerFunc) HandleFunc {
return func(ctx *Context) (err error) {
f(ctx.Response(), ctx.Request())
return
}
}