Documentation ¶
Index ¶
- type API
- type APIListener
- type Controller
- func (controller *Controller) AddAPIListeners(listeners ...APIListener)
- func (controller *Controller) AddRequestListeners(listeners ...RequestListener)
- func (controller *Controller) AddResponseListener(listeners ...ResponseListener)
- func (controller *Controller) AddRoutes(routes ...Route)
- func (controller *Controller) SetRoutePrefix(prefix string)
- type ErrorHandler
- type RequestBody
- type RequestContext
- type RequestListener
- type ResponseListener
- type Route
- type RouteCreationStage
- func OnDelete(path string) RouteCreationStage
- func OnGET(path string) RouteCreationStage
- func OnOptions(path string) RouteCreationStage
- func OnPOST(path string) RouteCreationStage
- func OnPUT(path string) RouteCreationStage
- func OnPatch(path string) RouteCreationStage
- func OnPath(path string) RouteCreationStage
- type Server
- func (server *Server) AddAPIListeners(listeners ...APIListener)
- func (server *Server) AddRequestListeners(listeners ...RequestListener)
- func (server *Server) AddResponseListeners(listeners ...ResponseListener)
- func (server *Server) MethodNowAllowedAction(action API)
- func (server *Server) NotFoundAction(action API)
- func (server *Server) Register(controllers ...*Controller)
- func (server *Server) ServerErrorAction(action ErrorHandler)
- func (server *Server) Start() error
- type Status
- func BadRequest(body any) Status
- func CreateResponse(statusCode int, body any) Status
- func Created(body any) Status
- func Forbidden(body any) Status
- func Found(location string) Status
- func InternalServerError(body any) Status
- func MethodNotAllowed(body any) Status
- func MovedPermanently(location string) Status
- func NotFound(body any) Status
- func Ok(body any) Status
- func PermanentRedirect(location string) Status
- func Unauthorized(body any) Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API = func(c RequestContext) Status
type APIListener ¶ added in v0.2.3
type APIListener = func(RequestContext, Status)
func WatchAPIs ¶
func WatchAPIs() APIListener
type Controller ¶
type Controller struct { Name string // contains filtered or unexported fields }
func NewController ¶
func NewController(name string) *Controller
func (*Controller) AddAPIListeners ¶ added in v0.2.3
func (controller *Controller) AddAPIListeners(listeners ...APIListener)
func (*Controller) AddRequestListeners ¶
func (controller *Controller) AddRequestListeners(listeners ...RequestListener)
func (*Controller) AddResponseListener ¶
func (controller *Controller) AddResponseListener(listeners ...ResponseListener)
func (*Controller) AddRoutes ¶
func (controller *Controller) AddRoutes(routes ...Route)
func (*Controller) SetRoutePrefix ¶
func (controller *Controller) SetRoutePrefix(prefix string)
type ErrorHandler ¶ added in v0.2.4
type ErrorHandler = func(request RequestContext, err any) Status
type RequestBody ¶
type RequestBody struct {
// contains filtered or unexported fields
}
func (*RequestBody) WriteInto ¶
func (rb *RequestBody) WriteInto(a any) error
type RequestContext ¶
type RequestContext struct { Url string QueryParams map[string][]string PathParams map[string]string Headers http.Header Body *RequestBody Method string ContentLength int64 Host string MultipartForm func() *multipart.Form // contains filtered or unexported fields }
func (RequestContext) GetPathParam ¶
func (c RequestContext) GetPathParam(name string) (string, bool)
func (RequestContext) GetQueries ¶
func (c RequestContext) GetQueries(name string) []string
type RequestListener ¶
type RequestListener = func(RequestContext) RequestContext
type ResponseListener ¶
type RouteCreationStage ¶
type RouteCreationStage struct {
// contains filtered or unexported fields
}
func OnDelete ¶
func OnDelete(path string) RouteCreationStage
func OnGET ¶
func OnGET(path string) RouteCreationStage
func OnOptions ¶ added in v0.2.2
func OnOptions(path string) RouteCreationStage
func OnPOST ¶
func OnPOST(path string) RouteCreationStage
func OnPUT ¶
func OnPUT(path string) RouteCreationStage
func OnPatch ¶
func OnPatch(path string) RouteCreationStage
func OnPath ¶
func OnPath(path string) RouteCreationStage
func (RouteCreationStage) Do ¶
func (stage RouteCreationStage) Do(api API) Route
func (RouteCreationStage) WithMethod ¶
func (stage RouteCreationStage) WithMethod(method string) RouteCreationStage
type Server ¶
type Server struct { Controllers []*Controller // contains filtered or unexported fields }
func (*Server) AddAPIListeners ¶ added in v0.2.3
func (server *Server) AddAPIListeners(listeners ...APIListener)
func (*Server) AddRequestListeners ¶
func (server *Server) AddRequestListeners(listeners ...RequestListener)
func (*Server) AddResponseListeners ¶
func (server *Server) AddResponseListeners(listeners ...ResponseListener)
func (*Server) MethodNowAllowedAction ¶ added in v0.2.2
func (*Server) NotFoundAction ¶ added in v0.2.2
func (*Server) Register ¶
func (server *Server) Register(controllers ...*Controller)
func (*Server) ServerErrorAction ¶ added in v0.2.3
func (server *Server) ServerErrorAction(action ErrorHandler)
type Status ¶
func BadRequest ¶
func CreateResponse ¶
func InternalServerError ¶
func MethodNotAllowed ¶ added in v0.2.2
func MovedPermanently ¶
func PermanentRedirect ¶
func Unauthorized ¶
Click to show internal directories.
Click to hide internal directories.