types.go 478 B

1234567891011121314151617181920212223242526
  1. package http
  2. import "net/http"
  3. type responsePayload struct {
  4. Code int `json:"code"`
  5. Reason string `json:"reason,omitempty"`
  6. Data any `json:"data,omitempty"`
  7. }
  8. type HandleFunc func(ctx *Context) (err error)
  9. type Middleware func(next HandleFunc) HandleFunc
  10. type Route struct {
  11. Method string
  12. Path string
  13. Handle HandleFunc
  14. }
  15. func Wrap(f http.HandlerFunc) HandleFunc {
  16. return func(ctx *Context) (err error) {
  17. f(ctx.Response(), ctx.Request())
  18. return
  19. }
  20. }