Documentation ¶
Index ¶
- Constants
- Variables
- func AssetsURL(ctx context.Context, path string, a ...any) string
- func BaseURL(ctx context.Context) string
- func LogoURL(ctx context.Context) string
- func OAuthBaseURL(ctx context.Context) string
- func ParseCookie(s string) *http.Cookie
- func TenantBaseURL(ctx context.Context, tenant *entity.Tenant) string
- type Cache
- type CertificateManager
- type Context
- func (c *Context) AddCookie(name, value string, expires time.Time) *http.Cookie
- func (c *Context) AddParam(name, value string)
- func (c *Context) Attachment(fileName, contentType string, file []byte) error
- func (c *Context) BadRequest(dict Map) error
- func (c *Context) BaseURL() string
- func (c *Context) Bind(i any) error
- func (c *Context) BindTo(i actions.Actionable) *validate.Result
- func (c *Context) Blob(code int, contentType string, b []byte) error
- func (c *Context) Commit() error
- func (c *Context) ContextID() string
- func (c *Context) Engine() *Engine
- func (c *Context) Enqueue(task worker.Task)
- func (c *Context) Failure(err error) error
- func (c *Context) Forbidden() error
- func (c *Context) GetMatchedRoutePath() string
- func (c *Context) Gone() error
- func (c *Context) HandleValidation(result *validate.Result) error
- func (c *Context) Image(contentType string, b []byte) error
- func (c *Context) IsAjax() bool
- func (c *Context) IsAuthenticated() bool
- func (c *Context) JSON(code int, i any) error
- func (c *Context) NoContent(code int) error
- func (c *Context) NotFound() error
- func (c *Context) Ok(data any) error
- func (c *Context) Page(code int, props Props) error
- func (c *Context) Param(name string) string
- func (c *Context) ParamAsInt(name string) (int, error)
- func (c *Context) PermanentRedirect(url string) error
- func (c *Context) QueryParam(key string) string
- func (c *Context) QueryParamAsArray(key string) []string
- func (c *Context) QueryParamAsInt(key string) (int, error)
- func (c *Context) Redirect(url string) error
- func (c *Context) RemoveCookie(name string)
- func (c *Context) Rollback()
- func (c *Context) SessionID() string
- func (c *Context) Set(key any, val any)
- func (c *Context) SetCanonicalURL(rawurl string)
- func (c *Context) SetSessionID(id string)
- func (c *Context) SetTenant(tenant *entity.Tenant)
- func (c *Context) SetUser(user *entity.User)
- func (c *Context) String(code int, text string) error
- func (c *Context) Tenant() *entity.Tenant
- func (c *Context) Unauthorized() error
- func (c *Context) User() *entity.User
- func (c *Context) XML(code int, text string) error
- type DefaultBinder
- type Engine
- func (e *Engine) Cache() *cache.Cache
- func (e *Engine) Delete(path string, handler HandlerFunc)
- func (e *Engine) Get(path string, handler HandlerFunc)
- func (e *Engine) Group() *Group
- func (e *Engine) NotFound(handler HandlerFunc)
- func (e *Engine) Post(path string, handler HandlerFunc)
- func (e *Engine) Put(path string, handler HandlerFunc)
- func (e *Engine) Start(address string)
- func (e *Engine) Stop() error
- func (e *Engine) Use(middleware MiddlewareFunc)
- func (e *Engine) Worker() worker.Worker
- type Group
- func (g *Group) Delete(path string, handler HandlerFunc)
- func (g *Group) Get(path string, handler HandlerFunc)
- func (g *Group) Group() *Group
- func (g *Group) Post(path string, handler HandlerFunc)
- func (g *Group) Put(path string, handler HandlerFunc)
- func (g *Group) Static(prefix, root string)
- func (g *Group) Use(middleware MiddlewareFunc)
- type HandlerFunc
- type Map
- type MiddlewareFunc
- type Props
- type ReactRenderer
- type Renderer
- type Request
- func (r *Request) AddCookie(cookie *http.Cookie)
- func (r *Request) BaseURL() string
- func (r *Request) Cookie(name string) (*http.Cookie, error)
- func (r *Request) GetHeader(key string) string
- func (r *Request) IsAPI() bool
- func (r *Request) IsCrawler() bool
- func (r *Request) IsCustomDomain() bool
- func (r *Request) SetHeader(key, value string)
- type Response
- type StringMap
Constants ¶
const CookieAuthName = "auth"
CookieAuthName is the name of the cookie that holds the Authentication Token
const CookieSessionName = "user_session_id"
CookieSessionName is the name of the cookie that holds the session ID
const CookieSignUpAuthName = "__signup_auth"
CookieSignUpAuthName is the name of the cookie that holds the temporary Authentication Token
Variables ¶
var ( PlainContentType = "text/plain" HTMLContentType = "text/html" JSONContentType = "application/json" XMLContentType = "application/xml" UTF8PlainContentType = PlainContentType + "; charset=utf-8" UTF8HTMLContentType = HTMLContentType + "; charset=utf-8" UTF8XMLContentType = XMLContentType + "; charset=utf-8" UTF8JSONContentType = JSONContentType + "; charset=utf-8" )
HTMLMimeType is the mimetype for HTML responses
var ( //CspPolicyTemplate is the template used to generate the policy CspPolicyTemplate = fmt.Sprintf("%s; %s; %s; %s; %s; %s; %s; %s; %s; %s", cspBase, cspDefault, cspStyle, cspScript, cspImage, cspFont, cspObject, cspMedia, cspConnect, cspFrame) )
var ( //ErrContentTypeNotAllowed is used when POSTing a body that is not json ErrContentTypeNotAllowed = stdErrors.New("Only Content-Type application/json is allowed") )
Functions ¶
func AssetsURL ¶ added in v0.19.0
AssetsURL return the full URL to a tenant-specific static asset It should always return an absolute URL
func OAuthBaseURL ¶ added in v0.18.1
OAuthBaseURL returns the OAuth base URL used for host-wide OAuth authentication For Single Tenant HostMode, BaseURL is the current BaseURL For Multi Tenant HostMode, BaseURL is //login.{HOST_DOMAIN}
func ParseCookie ¶ added in v0.15.0
ParseCookie return a list of cookie parsed from raw Set-Cookie
Types ¶
type Cache ¶ added in v0.18.1
type Cache struct { }
Cache provides a Blob backend to the autocert cache.
func NewAutoCertCache ¶ added in v0.18.1
func NewAutoCertCache() *Cache
NewAutoCertCache returns a new AutoCert cache using Blob Storage
func (*Cache) Delete ¶ added in v0.18.1
Delete removes a certificate data from the cache under the specified key. If there's no such key in the cache, Delete returns nil.
type CertificateManager ¶ added in v0.7.0
type CertificateManager struct {
// contains filtered or unexported fields
}
CertificateManager is used to manage SSL certificates
func NewCertificateManager ¶ added in v0.7.0
func NewCertificateManager(ctx context.Context, certFile, keyFile string) (*CertificateManager, error)
NewCertificateManager creates a new CertificateManager
func (*CertificateManager) GetCertificate ¶ added in v0.7.0
func (m *CertificateManager) GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, error)
GetCertificate decides which certificate to use It first tries to use loaded certificate for incoming request if it's compatible Otherwise fallsback to a automatically generated certificate by Let's Encrypt
func (*CertificateManager) StartHTTPServer ¶ added in v0.9.0
func (m *CertificateManager) StartHTTPServer()
StartHTTPServer creates a new HTTP server on port 80 that is used for the ACME HTTP Challenge
type Context ¶
type Context struct { context.Context Response Response Request Request // contains filtered or unexported fields }
Context shared between http pipeline
func NewContext ¶ added in v0.18.1
func NewContext(engine *Engine, req *http.Request, rw http.ResponseWriter, params StringMap) *Context
NewContext creates a new web Context
func (*Context) Attachment ¶ added in v0.12.0
Attachment returns an attached file
func (*Context) BadRequest ¶
BadRequest returns 400 BadRequest with JSON result
func (*Context) BindTo ¶ added in v0.4.0
func (c *Context) BindTo(i actions.Actionable) *validate.Result
BindTo context values into given model
func (*Context) Blob ¶ added in v0.7.0
Blob sends a blob response with status code and content type.
func (*Context) GetMatchedRoutePath ¶ added in v0.19.1
GetMatchedRoutePath returns the Matched Route name
func (*Context) HandleValidation ¶ added in v0.4.0
HandleValidation handles given validation result property to return 400 or 500
func (*Context) Image ¶ added in v0.18.0
Image sends an image blob response with status code and content type.
func (*Context) IsAuthenticated ¶
IsAuthenticated returns true if user is authenticated
func (*Context) NoContent ¶ added in v0.7.0
NoContent sends a response with no body and a status code.
func (*Context) ParamAsInt ¶
ParamAsInt returns parameter as int
func (*Context) PermanentRedirect ¶ added in v0.17.0
PermanentRedirect the request to a provided URL
func (*Context) QueryParam ¶ added in v0.7.0
QueryParam returns querystring parameter for given key
func (*Context) QueryParamAsArray ¶ added in v0.10.0
QueryParamAsArray returns querystring parameter for given key as an array
func (*Context) QueryParamAsInt ¶ added in v0.18.0
QueryParamAsInt returns querystring parameter for given key
func (*Context) RemoveCookie ¶ added in v0.6.0
RemoveCookie removes a cookie
func (*Context) Rollback ¶ added in v0.11.0
func (c *Context) Rollback()
Rollback everything that is pending on current context
func (*Context) SetCanonicalURL ¶ added in v0.18.0
SetCanonicalURL sets the canonical link on the HTTP Response Headers
func (*Context) SetSessionID ¶ added in v0.17.0
SetSessionID sets the session ID on current context
func (*Context) Unauthorized ¶ added in v0.4.0
Unauthorized returns a 401 error response
type DefaultBinder ¶ added in v0.7.0
type DefaultBinder struct { }
DefaultBinder is the default HTTP binder
func NewDefaultBinder ¶ added in v0.7.0
func NewDefaultBinder() *DefaultBinder
NewDefaultBinder creates a new default binder
type Engine ¶
Engine is our web engine wrapper
func (*Engine) Delete ¶ added in v0.15.0
func (e *Engine) Delete(path string, handler HandlerFunc)
Delete handles HTTP DELETE requests
func (*Engine) Get ¶ added in v0.15.0
func (e *Engine) Get(path string, handler HandlerFunc)
Get handles HTTP GET requests
func (*Engine) NotFound ¶ added in v0.16.0
func (e *Engine) NotFound(handler HandlerFunc)
NotFound register how to handle routes that are not found
func (*Engine) Post ¶ added in v0.15.0
func (e *Engine) Post(path string, handler HandlerFunc)
Post handles HTTP POST requests
func (*Engine) Put ¶ added in v0.15.0
func (e *Engine) Put(path string, handler HandlerFunc)
Put handles HTTP PUT requests
func (*Engine) Use ¶
func (e *Engine) Use(middleware MiddlewareFunc)
Use adds a middleware to the root engine
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group is our router group wrapper
func (*Group) Delete ¶ added in v0.8.0
func (g *Group) Delete(path string, handler HandlerFunc)
Delete handles HTTP DELETE requests
func (*Group) Get ¶
func (g *Group) Get(path string, handler HandlerFunc)
Get handles HTTP GET requests
func (*Group) Post ¶
func (g *Group) Post(path string, handler HandlerFunc)
Post handles HTTP POST requests
func (*Group) Put ¶ added in v0.15.0
func (g *Group) Put(path string, handler HandlerFunc)
Put handles HTTP PUT requests
func (*Group) Use ¶
func (g *Group) Use(middleware MiddlewareFunc)
Use adds a middleware to current route stack
type MiddlewareFunc ¶
type MiddlewareFunc func(HandlerFunc) HandlerFunc
MiddlewareFunc represents an HTTP middleware
type ReactRenderer ¶ added in v0.18.1
type ReactRenderer struct {
// contains filtered or unexported fields
}
func NewReactRenderer ¶ added in v0.18.1
func NewReactRenderer(scriptPath string) (*ReactRenderer, error)
type Renderer ¶ added in v0.7.0
type Renderer struct {
// contains filtered or unexported fields
}
Renderer is the default HTML Render
type Request ¶ added in v0.14.0
type Request struct { Method string ContentLength int64 Body string IsSecure bool StartTime time.Time URL *url.URL // contains filtered or unexported fields }
Request wraps the http request object
func WrapRequest ¶ added in v0.14.0
WrapRequest returns Fider wrapper of HTTP Request
func (*Request) GetHeader ¶ added in v0.14.0
GetHeader returns the value of HTTP header from given key
func (*Request) IsCrawler ¶ added in v0.18.0
IsCrawler returns true if the request is coming from a crawler
func (*Request) IsCustomDomain ¶ added in v0.20.0
IsCustomDomain returns true if the request was made using a custom domain (CNAME)
type Response ¶ added in v0.19.0
type Response struct { Writer http.ResponseWriter StatusCode int }
Response is a wrapper of http.ResponseWriter with access to the StatusCode