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 ¶
AssetsURL return the full URL to a tenant-specific static asset It should always return an absolute URL
func OAuthBaseURL ¶
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 ¶
ParseCookie return a list of cookie parsed from raw Set-Cookie
Types ¶
type Cache ¶
type Cache struct { }
Cache provides a Blob backend to the autocert cache.
func NewAutoCertCache ¶
func NewAutoCertCache() *Cache
NewAutoCertCache returns a new AutoCert cache using Blob Storage
func (*Cache) Delete ¶
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 ¶
type CertificateManager struct {
// contains filtered or unexported fields
}
CertificateManager is used to manage SSL certificates
func NewCertificateManager ¶
func NewCertificateManager(ctx context.Context, certFile, keyFile string) (*CertificateManager, error)
NewCertificateManager creates a new CertificateManager
func (*CertificateManager) GetCertificate ¶
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 ¶
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 ¶
func NewContext(engine *Engine, req *http.Request, rw http.ResponseWriter, params StringMap) *Context
NewContext creates a new web Context
func (*Context) Attachment ¶
Attachment returns an attached file
func (*Context) BadRequest ¶
BadRequest returns 400 BadRequest with JSON result
func (*Context) BindTo ¶
func (c *Context) BindTo(i actions.Actionable) *validate.Result
BindTo context values into given model
func (*Context) GetMatchedRoutePath ¶
GetMatchedRoutePath returns the Matched Route name
func (*Context) HandleValidation ¶
HandleValidation handles given validation result property to return 400 or 500
func (*Context) IsAuthenticated ¶
IsAuthenticated returns true if user is authenticated
func (*Context) ParamAsInt ¶
ParamAsInt returns parameter as int
func (*Context) PermanentRedirect ¶
PermanentRedirect the request to a provided URL
func (*Context) QueryParam ¶
QueryParam returns querystring parameter for given key
func (*Context) QueryParamAsArray ¶
QueryParamAsArray returns querystring parameter for given key as an array
func (*Context) QueryParamAsInt ¶
QueryParamAsInt returns querystring parameter for given key
func (*Context) RemoveCookie ¶
RemoveCookie removes a cookie
func (*Context) Rollback ¶
func (c *Context) Rollback()
Rollback everything that is pending on current context
func (*Context) SetCanonicalURL ¶
SetCanonicalURL sets the canonical link on the HTTP Response Headers
func (*Context) SetSessionID ¶
SetSessionID sets the session ID on current context
func (*Context) Unauthorized ¶
Unauthorized returns a 401 error response
type DefaultBinder ¶
type DefaultBinder struct { }
DefaultBinder is the default HTTP binder
func NewDefaultBinder ¶
func NewDefaultBinder() *DefaultBinder
NewDefaultBinder creates a new default binder
type Engine ¶
Engine is our web engine wrapper
func (*Engine) Delete ¶
func (e *Engine) Delete(path string, handler HandlerFunc)
Delete handles HTTP DELETE requests
func (*Engine) Get ¶
func (e *Engine) Get(path string, handler HandlerFunc)
Get handles HTTP GET requests
func (*Engine) NotFound ¶
func (e *Engine) NotFound(handler HandlerFunc)
NotFound register how to handle routes that are not found
func (*Engine) Post ¶
func (e *Engine) Post(path string, handler HandlerFunc)
Post handles HTTP POST requests
func (*Engine) Put ¶
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 ¶
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 ¶
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 ¶
type ReactRenderer struct {
// contains filtered or unexported fields
}
func NewReactRenderer ¶
func NewReactRenderer(scriptPath string) (*ReactRenderer, error)
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer is the default HTML Render
type Request ¶
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 ¶
WrapRequest returns Templates wrapper of HTTP Request
func (*Request) IsCustomDomain ¶
IsCustomDomain returns true if the request was made using a custom domain (CNAME)
type Response ¶
type Response struct { Writer http.ResponseWriter StatusCode int }
Response is a wrapper of http.ResponseWriter with access to the StatusCode