neko/pkg/types/http.go

28 lines
679 B
Go
Raw Permalink Normal View History

2021-09-17 10:24:33 +12:00
package types
import (
"context"
"net/http"
)
type RouterHandler func(w http.ResponseWriter, r *http.Request) error
type MiddlewareHandler func(w http.ResponseWriter, r *http.Request) (context.Context, error)
type Router interface {
Group(fn func(Router))
Route(pattern string, fn func(Router))
Get(pattern string, fn RouterHandler)
Post(pattern string, fn RouterHandler)
Put(pattern string, fn RouterHandler)
2022-04-14 20:47:47 +12:00
Patch(pattern string, fn RouterHandler)
2021-09-17 10:24:33 +12:00
Delete(pattern string, fn RouterHandler)
With(fn MiddlewareHandler) Router
Use(fn MiddlewareHandler)
ServeHTTP(w http.ResponseWriter, req *http.Request)
}
type HttpManager interface {
Start()
Shutdown() error
}