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 MalformedRequestContext
- type Param
- type Params
- type ParseError
- 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) SetErrorHandler(action ErrorHandler)
- func (server *Server) Start() error
- func (server *Server) Stop()
- 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)
var WatchAPIs APIListener = func(request RequestContext, status Status) { now := time.Now() difference := fmt.Sprint(now.Sub(request.receivedAt)) statusString := fmt.Sprintf("%v%d%v", getColor(status.StatusCode), status.StatusCode, colored.ResetPrevColor) stginLogger.InfoF("%v -> %v | %v | %v", request.Method, request.Url, statusString, difference) }
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 MalformedRequestContext ¶ added in v0.2.5
type MalformedRequestContext struct {
// contains filtered or unexported fields
}
func (MalformedRequestContext) Error ¶ added in v0.2.5
func (mrc MalformedRequestContext) Error() string
type Param ¶ added in v0.2.6
type Param struct {
// contains filtered or unexported fields
}
func MatchAndExtractPathParams ¶ added in v0.3.5
type ParseError ¶ added in v0.2.5
type ParseError struct {
// contains filtered or unexported fields
}
func (ParseError) Error ¶ added in v0.2.5
func (ije ParseError) Error() string
type RequestBody ¶
type RequestBody struct {
// contains filtered or unexported fields
}
func (*RequestBody) JSONInto ¶ added in v0.2.5
func (body *RequestBody) JSONInto(a any)
func (*RequestBody) SafeJSONInto ¶ added in v0.2.5
func (body *RequestBody) SafeJSONInto(a any) error
func (*RequestBody) SafeXMLInto ¶ added in v0.2.5
func (body *RequestBody) SafeXMLInto(a any) error
func (*RequestBody) XMLInto ¶ added in v0.2.5
func (body *RequestBody) XMLInto(a any)
type RequestContext ¶
type RequestContext struct { Url string QueryParams map[string][]string PathParams Params Headers http.Header Body *RequestBody Method string ContentLength int64 Host string MultipartForm func() *multipart.Form Scheme string RemoteAddr string // 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
func (RequestContext) MustGetPathParam ¶ added in v0.3.2
func (c RequestContext) MustGetPathParam(name string) string
type RequestListener ¶
type RequestListener = func(RequestContext) RequestContext
type ResponseListener ¶
type Route ¶
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) SetErrorHandler ¶ added in v0.2.5
func (server *Server) SetErrorHandler(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.