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
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 { Success bool `json:"success"` 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 NewRouter ¶
func NewRouter(config *RouterConfig) (*Router, error)
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 PerDomainHijack map[string][]func(r *Router, spath []string, w http.ResponseWriter, req *http.Request, domain string) bool AllowCustomHeaders []string AllowOrigins []string // 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 }
Click to show internal directories.
Click to hide internal directories.