Documentation ¶
Index ¶
- type CookieOptions
- type Cookies
- type Request
- func (c *Request[Req]) GetFile(fieldName string) (multipart.File, *multipart.FileHeader, error)
- func (c *Request[Req]) GetForm(formName string) string
- func (c *Request[Req]) GetHeader(header string) string
- func (c *Request[Req]) GetIP() string
- func (c *Request[Req]) GetPathParam(pathParam string) string
- func (c *Request[Req]) GetPathParamDefault(pathParam, defaultValue string) string
- func (c *Request[Req]) GetQueryParam(queryParam string) string
- func (c *Request[Req]) GetQueryParamDefault(queryParam, defaultValue string) string
- func (c *Request[Req]) Json(statusCode int, data any) error
- func (c *Request[Req]) Redirect(statusCode int, url string)
- func (c *Request[Req]) Text(statusCode int, message string)
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CookieOptions ¶
type CookieOptions struct { Path string Domain string MaxAge int Secure bool HttpOnly bool SameSite http.SameSite Expires time.Time }
CookieOptions represents the options for setting a cookie.
type Cookies ¶
type Cookies struct { Request *http.Request Response http.ResponseWriter }
Cookies abstraction
func (*Cookies) SetCookie ¶
func (co *Cookies) SetCookie(name, value string, options *CookieOptions)
SetCookie sets an HTTP cookie in the response using flexible options.
type Request ¶
type Request[Req any] struct { Request *http.Request Response http.ResponseWriter Cookies Cookies Body Req }
Request is a generic context struct that holds the HTTP request and response, along with a body of type Req. It is used to pass around the HTTP request and response objects, as well as any additional data needed for processing the request.
Type Parameters:
Req - The type of the body data.
Fields:
Request - The HTTP request object. Response - The HTTP response writer. Body - The body data of type Req.
func (*Request[Req]) GetPathParam ¶
GetPathParam retrieves a placeholder value from the URL path.
func (*Request[Req]) GetPathParamDefault ¶
GetPathParamDefault retrieves a path parameter value or returns a default value if not found.
func (*Request[Req]) GetQueryParam ¶
GetQueryParam retrieves the value of a specific query parameter.
func (*Request[Req]) GetQueryParamDefault ¶
GetQueryParamDefault retrieves a query parameter value or returns a default value if not found.
func (*Request[Req]) Json ¶
Json writes a JSON response to the client with the specified status code.