Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIErrorResponse ¶
type APIErrorResponse struct { StatusCode HttpStatusCode `json:"status_code"` Status string `json:"status"` Error string `json:"error"` ErrorCode int `json:"error_code"` Details map[string]interface{} `json:"details,omitempty"` }
type Ctx ¶
type Ctx struct { Lifecycle *Lifecycle *fasthttp.RequestCtx }
func (*Ctx) JSON ¶
func (c *Ctx) JSON(status HttpStatusCode, v interface{}) APIError
func (*Ctx) SetActor ¶
func (c *Ctx) SetActor(u *structures.User)
Set the current authenticated user
func (*Ctx) SetStatusCode ¶
func (c *Ctx) SetStatusCode(code HttpStatusCode)
func (*Ctx) StatusCode ¶
func (c *Ctx) StatusCode() HttpStatusCode
type HttpStatusCode ¶
type HttpStatusCode int
const ( // 1xx Informational Continue HttpStatusCode = 100 SwitchingProtocol HttpStatusCode = 101 Processing HttpStatusCode = 102 EarlyHints HttpStatusCode = 103 // 2xx Successful OK HttpStatusCode = 200 Created HttpStatusCode = 201 Accepted HttpStatusCode = 202 NonAuthoritativeInformation HttpStatusCode = 203 NoContent HttpStatusCode = 204 ResetContent HttpStatusCode = 205 PartialContent HttpStatusCode = 206 MultiStatus HttpStatusCode = 207 AlreadyReported HttpStatusCode = 208 IMUsed HttpStatusCode = 226 // 3xx Redirections MultipleChoice HttpStatusCode = 300 MovedPermanently HttpStatusCode = 301 Found HttpStatusCode = 302 SeeOther HttpStatusCode = 303 NotModified HttpStatusCode = 304 TemporaryRedirect HttpStatusCode = 307 PermanentRedirect HttpStatusCode = 308 // 4xx Client Errors BadRequest HttpStatusCode = 400 PaymentRequired HttpStatusCode = 402 Forbidden HttpStatusCode = 403 NotFound HttpStatusCode = 404 MethodNotAllowed HttpStatusCode = 405 NotAcceptable HttpStatusCode = 406 ProxyAuthenticationRequired HttpStatusCode = 407 RequestTimeout HttpStatusCode = 408 Conflict HttpStatusCode = 409 Gone HttpStatusCode = 410 LengthRequired HttpStatusCode = 411 PreconditionFailed HttpStatusCode = 412 PayloadTooLarge HttpStatusCode = 413 URITooLong HttpStatusCode = 414 UnsupportedMediaType HttpStatusCode = 415 RangeNotSatisfiable HttpStatusCode = 416 ExpectationFailed HttpStatusCode = 417 ImATeapot HttpStatusCode = 418 MisdirectedRequest HttpStatusCode = 421 UnprocessableEntity HttpStatusCode = 422 Locked HttpStatusCode = 423 FailedDependency HttpStatusCode = 424 TooEarly HttpStatusCode = 425 UpgradeRequired HttpStatusCode = 426 PreconditionRequired HttpStatusCode = 428 TooManyRequests HttpStatusCode = 429 RequestHeaderFieldsTooLarge HttpStatusCode = 431 // 5xx Server Errors InternalServerError HttpStatusCode = 500 NotImplemented HttpStatusCode = 501 BadGateway HttpStatusCode = 502 GatewayTimeout HttpStatusCode = 504 HttpVersionNotSupported HttpStatusCode = 505 VariantAlsoNegotiates HttpStatusCode = 506 InsufficientStorage HttpStatusCode = 507 LoopDetected HttpStatusCode = 508 NotExtended HttpStatusCode = 510 NetworkAuthenticationRequired HttpStatusCode = 511 )
func (HttpStatusCode) String ¶
func (c HttpStatusCode) String() string
String: return the http status code in text form
type Lifecycle ¶
type Lifecycle struct {
// contains filtered or unexported fields
}
func NewLifecycle ¶
func (*Lifecycle) Write ¶
func (l *Lifecycle) Write(event LifecyclePhase, d LifecycleEventData)
Write: send a lifecycle event
type LifecycleEventData ¶
type LifecycleEventData interface{}
type LifecyclePhase ¶
type LifecyclePhase int
const ( LifecyclePhaseStarted LifecyclePhase = 1 + iota LifecyclePhaseWriteHeader LifecyclePhaseWriteBody LifecyclePhaseSetStatus LifecyclePhaseCompleted )
type Middleware ¶
type Route ¶
type Route interface { Config() RouteConfig Handler(ctx *Ctx) APIError }
type RouteConfig ¶
type RouteConfig struct { URI string Method RouteMethod Children []Route Middleware []Middleware }
type RouteMethod ¶
type RouteMethod string
const ( GET RouteMethod = "GET" POST RouteMethod = "POST" PUT RouteMethod = "PUT" PATCH RouteMethod = "PATCH" DELETE RouteMethod = "DELETE" OPTIONS RouteMethod = "OPTIONS" )
Click to show internal directories.
Click to hide internal directories.