27 lines
478 B
Go
27 lines
478 B
Go
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
|
|
}
|
|
}
|