Documentation
¶
Index ¶
- Constants
- type Component
- type Ctx
- func (c Ctx) Accept() string
- func (c Ctx) AcceptsHTML() bool
- func (c Ctx) AcceptsJSON() bool
- func (c Ctx) AcceptsPlainText() bool
- func (c Ctx) AddHeader(key, value string)
- func (c Ctx) Context() context.Context
- func (c Ctx) Error(code int, message any) servererror.Error
- func (c Ctx) GetCookie(name string) string
- func (c Ctx) GetCurrentAccount() adapter.Account
- func (c Ctx) GetRequestHeader(key string) string
- func (c Ctx) ID() string
- func (c Ctx) Method() string
- func (c Ctx) Next() error
- func (c Ctx) Param(key string) string
- func (c Ctx) Path() string
- func (c Ctx) Redirect(code int, url string) error
- func (c Ctx) Render(f Component) error
- func (c Ctx) SendAttachment(filename string, contents *bytes.Buffer) error
- func (c Ctx) SendHTML(s string) error
- func (c Ctx) SendJSON(obj any) error
- func (c Ctx) SendString(s string) error
- func (c Ctx) Session() *session.Session
- func (c Ctx) SetContentType(contentType string)
- func (c Ctx) SetCookie(name, value string, expire time.Duration)
- func (c Ctx) SetCurrentAccount(a adapter.Account)
- func (c Ctx) SetHeader(key, value string)
- func (c Ctx) Status() int
- func (c Ctx) Store() *store.Service
- func (c Ctx) URL() *url.URL
- func (c Ctx) UnmarshalAndValidate(dest any) error
- func (c Ctx) UnmarshalBody(dest any) error
- func (c Ctx) UserIP() string
- func (c Ctx) WithContext(reqCtx context.Context) Ctx
- func (c Ctx) WithHeader(key, value string) Ctx
- func (c Ctx) WithStatus(code int) Ctx
- func (c Ctx) Write(b []byte) error
- type Handler
Constants ¶
const MaxBodySize int64 = 1 << 20
MaxBodySize is the default maximum request body size (1 MB)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ctx ¶
type Ctx struct {
// contains filtered or unexported fields
}
func (Ctx) AcceptsHTML ¶
func (Ctx) AcceptsJSON ¶
func (Ctx) AcceptsPlainText ¶
func (Ctx) AddHeader ¶
AddHeader appends a value to an existing header (multiple values for same key)
func (Ctx) Error ¶
func (c Ctx) Error(code int, message any) servererror.Error
helper to compose an HttpError to be used as error return
func (Ctx) GetCurrentAccount ¶
func (Ctx) GetRequestHeader ¶
func (Ctx) Redirect ¶
Redirect sends an HTTP redirect to the given URL with the specified status code. Common codes: http.StatusMovedPermanently (301), http.StatusFound (302), http.StatusSeeOther (303), http.StatusTemporaryRedirect (307).
func (Ctx) SendAttachment ¶
Content-type: filename extension mime type Content-Disposition: attachment; filename="logo.png" Status: http.StatusOK if no prior code is set
func (Ctx) SendHTML ¶
set content-type as text/html and write the html string set status to http.StatusOK if no prior code is set
func (Ctx) SendJSON ¶
set content-type as application/html and write marshalled object as json string set status to http.StatusOK if no prior code is set
func (Ctx) SendString ¶
set content-type as text/plain and write the string set status to http.StatusOK if no prior code is set
func (Ctx) SetContentType ¶
func (Ctx) SetCurrentAccount ¶
func (Ctx) UnmarshalAndValidate ¶
UnmarshalAndValidate deserializes the JSON request body into dest and runs struct validation using go-playground/validator tags.
func (Ctx) UnmarshalBody ¶
UnmarshalBody deserializes the JSON request body into dest, limiting the body size to prevent abuse.
func (Ctx) WithContext ¶
WithContext returns a copy of Ctx with the request context replaced. Use this for deadlines, cancellation or passing values to downstream handlers.
func (Ctx) WithHeader ¶
func (Ctx) WithStatus ¶
explicit status code, set it before any write