Documentation ¶
Index ¶
- Constants
- func StatusText(code int) string
- type Context
- type ContextRequest
- type ContextResponse
- type FormRequest
- type HandlerFunc
- type Json
- type Limit
- type Middleware
- type RateLimiter
- type ResourceController
- type Response
- type ResponseOrigin
- type ResponseStatus
- type ResponseSuccess
- type ResponseView
- type View
Constants ¶
View Source
const ( MethodGet = http.MethodGet MethodHead = http.MethodHead MethodPost = http.MethodPost MethodPut = http.MethodPut MethodPatch = http.MethodPatch MethodDelete = http.MethodDelete MethodConnect = http.MethodConnect MethodOptions = http.MethodOptions MethodTrace = http.MethodTrace )
View Source
const ( StatusContinue = http.StatusContinue StatusSwitchingProtocols = http.StatusSwitchingProtocols StatusProcessing = http.StatusProcessing StatusEarlyHints = http.StatusEarlyHints StatusOK = http.StatusOK StatusCreated = http.StatusCreated StatusAccepted = http.StatusAccepted StatusNonAuthoritativeInfo = http.StatusNonAuthoritativeInfo StatusNoContent = http.StatusNoContent StatusResetContent = http.StatusResetContent StatusPartialContent = http.StatusPartialContent StatusMultiStatus = http.StatusMultiStatus StatusAlreadyReported = http.StatusAlreadyReported StatusIMUsed = http.StatusIMUsed StatusMultipleChoices = http.StatusMultipleChoices StatusMovedPermanently = http.StatusMovedPermanently StatusFound = http.StatusFound StatusSeeOther = http.StatusSeeOther StatusNotModified = http.StatusNotModified StatusUseProxy = http.StatusUseProxy StatusTemporaryRedirect = http.StatusTemporaryRedirect StatusPermanentRedirect = http.StatusPermanentRedirect StatusBadRequest = http.StatusBadRequest StatusPaymentRequired = http.StatusPaymentRequired StatusForbidden = http.StatusForbidden StatusNotFound = http.StatusNotFound StatusMethodNotAllowed = http.StatusMethodNotAllowed StatusNotAcceptable = http.StatusNotAcceptable StatusProxyAuthRequired = http.StatusProxyAuthRequired StatusRequestTimeout = http.StatusRequestTimeout StatusConflict = http.StatusConflict StatusGone = http.StatusGone StatusLengthRequired = http.StatusLengthRequired StatusPreconditionFailed = http.StatusPreconditionFailed StatusRequestEntityTooLarge = http.StatusRequestEntityTooLarge StatusRequestURITooLong = http.StatusRequestURITooLong StatusUnsupportedMediaType = http.StatusUnsupportedMediaType StatusRequestedRangeNotSatisfiable = http.StatusRequestedRangeNotSatisfiable StatusExpectationFailed = http.StatusExpectationFailed StatusTeapot = http.StatusTeapot StatusMisdirectedRequest = http.StatusMisdirectedRequest StatusUnprocessableEntity = http.StatusUnprocessableEntity StatusLocked = http.StatusLocked StatusFailedDependency = http.StatusFailedDependency StatusTooEarly = http.StatusTooEarly StatusUpgradeRequired = http.StatusUpgradeRequired StatusPreconditionRequired = http.StatusPreconditionRequired StatusTooManyRequests = http.StatusTooManyRequests StatusRequestHeaderFieldsTooLarge = http.StatusRequestHeaderFieldsTooLarge StatusInternalServerError = http.StatusInternalServerError StatusNotImplemented = http.StatusNotImplemented StatusBadGateway = http.StatusBadGateway StatusGatewayTimeout = http.StatusGatewayTimeout StatusHTTPVersionNotSupported = http.StatusHTTPVersionNotSupported StatusVariantAlsoNegotiates = http.StatusVariantAlsoNegotiates StatusInsufficientStorage = http.StatusInsufficientStorage StatusLoopDetected = http.StatusLoopDetected StatusNotExtended = http.StatusNotExtended StatusNetworkAuthenticationRequired = http.StatusNetworkAuthenticationRequired )
Variables ¶
This section is empty.
Functions ¶
func StatusText ¶ added in v1.10.0
StatusText returns a text for the HTTP status code. It returns the empty string if the code is unknown.
Types ¶
type Context ¶ added in v1.0.1
type Context interface { context.Context // Context returns the Context Context() context.Context // WithValue add value associated with key in context WithValue(key string, value any) // Request returns the ContextRequest Request() ContextRequest // Response returns the ContextResponse Response() ContextResponse }
type ContextRequest ¶ added in v1.13.1
type ContextRequest interface { // Header retrieves the value of the specified HTTP header by its key. // If the header is not found, it returns the optional default value (if provided). Header(key string, defaultValue ...string) string // Headers return all the HTTP headers of the request. Headers() http.Header // Method retrieves the HTTP request method (e.g., GET, POST, PUT). Method() string // Path retrieves the current path information for the request. Path() string // Url retrieves the URL (excluding the query string) for the request. Url() string // FullUrl retrieves the full URL, including the query string, for the request. FullUrl() string // Ip retrieves the client's IP address. Ip() string // Host retrieves the host name. Host() string // All retrieves data from JSON, form, and query parameters. All() map[string]any // Bind retrieve json and bind to obj Bind(obj any) error // Route retrieves a route parameter from the request path (e.g., /users/{id}). Route(key string) string // RouteInt retrieves a route parameter from the request path and attempts to parse it as an integer. RouteInt(key string) int // RouteInt64 retrieves a route parameter from the request path and attempts to parse it as a 64-bit integer. RouteInt64(key string) int64 // Query retrieves a query string parameter from the request (e.g., /users?id=1). Query(key string, defaultValue ...string) string // QueryInt retrieves a query string parameter from the request and attempts to parse it as an integer. QueryInt(key string, defaultValue ...int) int // QueryInt64 retrieves a query string parameter from the request and attempts to parse it as a 64-bit integer. QueryInt64(key string, defaultValue ...int64) int64 // QueryBool retrieves a query string parameter from the request and attempts to parse it as a boolean. QueryBool(key string, defaultValue ...bool) bool // QueryArray retrieves a query string parameter from the request and returns it as a slice of strings. QueryArray(key string) []string // QueryMap retrieves a query string parameter from the request and returns it as a map of key-value pairs. QueryMap(key string) map[string]string // Queries returns all the query string parameters from the request as a map of key-value pairs. Queries() map[string]string // Input retrieves data from the request in the following order: JSON, form, query, and route parameters. Input(key string, defaultValue ...string) string InputArray(key string, defaultValue ...[]string) []string InputMap(key string, defaultValue ...map[string]string) map[string]string InputInt(key string, defaultValue ...int) int InputInt64(key string, defaultValue ...int64) int64 InputBool(key string, defaultValue ...bool) bool // File retrieves a file by its key from the request. File(name string) (filesystem.File, error) // AbortWithStatus aborts the request with the specified HTTP status code. AbortWithStatus(code int) // AbortWithStatusJson aborts the request with the specified HTTP status code // and returns a JSON response object. AbortWithStatusJson(code int, jsonObj any) // Next skips the current request handler, allowing the next middleware or handler to be executed. Next() // Origin retrieves the underlying *http.Request object for advanced request handling. Origin() *http.Request // Validate performs request data validation using specified rules and options. Validate(rules map[string]string, options ...validation.Option) (validation.Validator, error) // ValidateRequest validates the request data against a pre-defined FormRequest structure // and returns validation errors, if any. ValidateRequest(request FormRequest) (validation.Errors, error) }
type ContextResponse ¶ added in v1.13.1
type ContextResponse interface { // Data write the given data to the response. Data(code int, contentType string, data []byte) Response // Download initiates a file download by specifying the file path and the desired filename Download(filepath, filename string) Response // File serves a file located at the specified file path as the response. File(filepath string) Response // Header sets an HTTP header field with the given key and value. Header(key, value string) ContextResponse // Json sends a JSON response with the specified status code and data object. Json(code int, obj any) Response // Origin returns the ResponseOrigin Origin() ResponseOrigin // Redirect performs an HTTP redirect to the specified location with the given status code. Redirect(code int, location string) Response // String writes a string response with the specified status code and format. // The 'values' parameter can be used to replace placeholders in the format string. String(code int, format string, values ...any) Response // Success returns ResponseSuccess Success() ResponseSuccess // Status sets the HTTP response status code and returns the ResponseStatus. Status(code int) ResponseStatus // View returns ResponseView View() ResponseView // Writer returns the underlying http.ResponseWriter associated with the response. Writer() http.ResponseWriter // Flush flushes any buffered data to the client. Flush() }
type FormRequest ¶
type FormRequest interface { // Authorize determine if the user is authorized to make this request. Authorize(ctx Context) error // Rules get the validation rules that apply to the request. Rules(ctx Context) map[string]string // Messages get the validation messages that apply to the request. Messages(ctx Context) map[string]string // Attributes get custom attributes for validator errors. Attributes(ctx Context) map[string]string // PrepareForValidation prepare the data for validation. PrepareForValidation(ctx Context, data validation.Data) error }
type HandlerFunc ¶ added in v1.0.0
type Middleware ¶ added in v1.0.0
type Middleware func(Context)
type RateLimiter ¶ added in v1.10.0
type RateLimiter interface { // For register a new rate limiter. For(name string, callback func(ctx Context) Limit) // ForWithLimits register a new rate limiter with limits. ForWithLimits(name string, callback func(ctx Context) []Limit) // Limiter get a rate limiter instance by name. Limiter(name string) func(ctx Context) []Limit }
type ResourceController ¶ added in v1.11.1
type ResourceController interface { // Index method for controller Index(Context) Response // Show method for controller Show(Context) Response // Store method for controller Store(Context) Response // Update method for controller Update(Context) Response // Destroy method for controller Destroy(Context) Response }
type ResponseOrigin ¶ added in v1.8.0
type ResponseOrigin interface { // Body returns the response's body content as a *bytes.Buffer. Body() *bytes.Buffer // Header returns the response's HTTP header. Header() http.Header // Size returns the size, in bytes, of the response's body content. Size() int // Status returns the HTTP status code of the response. Status() int }
type ResponseStatus ¶ added in v1.12.5
type ResponseStatus interface { // Data write the given data to the Response. Data(contentType string, data []byte) Response // Json sends a JSON Response with the specified data object. Json(obj any) Response // String writes a string Response with the specified format and values. String(format string, values ...any) Response }
type ResponseSuccess ¶ added in v1.0.0
type ResponseSuccess interface { // Data write the given data to the Response. Data(contentType string, data []byte) Response // Json sends a JSON Response with the specified data object. Json(obj any) Response // String writes a string Response with the specified format and values. String(format string, values ...any) Response }
type ResponseView ¶ added in v1.13.1
type View ¶ added in v1.13.1
type View interface { // Exists checks if a view with the specified name exists. Exists(view string) bool // with the current view context. This shared data can be accessed by other parts of the application. Share(key string, value any) // If the key does not exist, it returns the optional default value (if provided). Shared(key string, def ...any) any GetShared() map[string]any }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.