Documentation ¶
Index ¶
- Variables
- func CORS(options CorsOptions)
- func Dir(path string) string
- func Ext(path string) (string, error)
- func Get[T any](target any, keys ...string) T
- func Init() *router
- func Refresh(options RefreshOptions)
- func Session(options SessionOptions)
- type Context
- func (c *Context) Cookie(name string, value string, attributes CookieAttributes) error
- func (c *Context) File(code int, path string) error
- func (c *Context) JSON(code int, body any) error
- func (c *Context) Next() error
- func (c *Context) Redirect(path string) error
- func (c *Context) ResHeaders() map[string][]string
- func (c *Context) SetHeader(name string, value string) error
- func (c *Context) SetRefresh(accesstoken_payload any, refreshtoken_payload any) error
- func (c *Context) SetSession(payload any) error
- func (c *Context) Status(code int) error
- func (c *Context) Text(code int, body string) error
- type CookieAttributes
- type CorsOptions
- type RefreshOptions
- type SessionOptions
- type TokenOptions
Constants ¶
This section is empty.
Variables ¶
View Source
var Status status = status{
100, 101, 102, 103,
200, 201, 202, 203, 204, 205, 206, 207, 208, 226,
300, 301, 302, 303, 304, 305, 306, 307, 308,
400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 421, 422, 423, 424, 425, 426, 428, 429, 431, 451,
500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511,
}
Functions ¶
func CORS ¶
func CORS(options CorsOptions)
Set Cross-Origin Resource Sharing headers and handle OPTIONS requests
func Refresh ¶
func Refresh(options RefreshOptions)
creates a refresh middleware
will create refresh and access tokens
searches for the "authorization" header with bearer when it comes to access token
func Session ¶
func Session(options SessionOptions)
Initialize Sessions
returns Session middleware
NOTE: sqlite3 is used as session store meaning that a gcc compiler is needed
Types ¶
type Context ¶
type Context struct { Url string Method string Headers map[string]string Body any // Body from the http request Session any // Session payload received from the Session middleware Refresh any // Refresh payload received from the Refresh middleware Error []error Params map[string]string Query map[string]string Cookies map[string]string Raw []byte // contains filtered or unexported fields }
func (*Context) Cookie ¶
func (c *Context) Cookie(name string, value string, attributes CookieAttributes) error
Set a cookie
func (*Context) File ¶
Send file data to the request endpoint
mime types like images, zips, fonts, audio, pdf and mp4 files are calculated.
mime types from e.g. script files that is in need for a sniffing technique is found through file extension
func (*Context) ResHeaders ¶
returns set response headers
type CookieAttributes ¶
type CorsOptions ¶
type RefreshOptions ¶
type RefreshOptions struct { AccessToken TokenOptions RefreshToken TokenOptions RefreshFunction func(refreshobj any) (any, error) // retrieve payload you plan to store inside access token Cookie CookieAttributes // contains filtered or unexported fields }
type SessionOptions ¶
type SessionOptions struct { Secret string // String used in session id hashing TimeOut int // Milliseconds until session is expired in the session store, defaults to 24 hours ClearProbability float64 // value between 0 - 100 that represents the chance of fox clearing expired sessions Path string // path to the session store Cookie CookieAttributes // contains filtered or unexported fields }
type TokenOptions ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.