Documentation
¶
Index ¶
- func JSONMarshal(t interface{}) ([]byte, error)
- func MarshalJSONErr(message, code string, args ...any) []byte
- func SendError(w http.ResponseWriter, message, code string, statusCode int)
- func SendErrorAndLog(w http.ResponseWriter, message, code string, statusCode int, origin string, ...)
- func SendInternalError(w http.ResponseWriter, origin string, err error)
- func SendSuccess(w http.ResponseWriter, resp interface{})
- type JSONErr
- type Router
- type RouterConfig
- type RouterConfigAddr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalJSONErr ¶
func SendErrorAndLog ¶
func SendInternalError ¶
func SendInternalError(w http.ResponseWriter, origin string, err error)
func SendSuccess ¶
func SendSuccess(w http.ResponseWriter, resp interface{})
Types ¶
type JSONErr ¶
type JSONErr struct {
Message string `json:"message,omitempty"`
Code string `json:"code,omitempty"`
}
func UnmarshalJSONErr ¶
type Router ¶
type Router struct {
State any
// contains filtered or unexported fields
}
func (*Router) ListenAndServe ¶
type RouterConfig ¶
type RouterConfig struct {
// any struct or map you may need
State any
// folder path
ServeHTMLFolder string
HTMLFolderDomainNames []string
PageViewsPath string
RedirectHTTP2HTTPS bool
OnlyHTTPS bool
DoNoRedirectToHTTPS []string // array of domain names
PerDomainHijack map[string][]func(
ctx context.Context, r *Router, spath []string, w http.ResponseWriter, req *http.Request, domain string,
) (next bool)
AllowCustomHeaders []string
AllowOrigins []string
AllowSSLOnDomains []string // may contain * to match any identifier between two separator points
SendError func(w http.ResponseWriter, message string, code string, statusCode int)
// If set to true, we ignore files that are not user+group+world readable on the local filesystem,
// so even if you accidentally copy a sensitive file into the web root, it's unlikely to be served.
IgnoreNotWorldReadable bool
ListenAddrs []*RouterConfigAddr
ReadHeaderTimeout time.Duration
ReadTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
LogLevel logging.LogLevel
}
type RouterConfigAddr ¶
Click to show internal directories.
Click to hide internal directories.