Documentation ¶
Overview ¶
Package web is a super minimalistic web/http server library
Index ¶
- func PathLast(r *http.Request) (string, int)
- func TemplateParseFSRecursive(templates fs.FS, ext string, nonRootTemplateNames bool, ...) (*template.Template, error)
- type Action
- type Headers
- type Hyperlink
- type Response
- func Data(status int, content []byte, headers Headers) *Response
- func DataJSON(status int, v interface{}, headers Headers) *Response
- func Empty(status int) *Response
- func Error(status int, err error, headers Headers) *Response
- func ErrorJSON(status int, err error, headers Headers) *Response
- func HTML(status int, t *template.Template, template string, data interface{}, ...) *Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TemplateParseFSRecursive ¶
func TemplateParseFSRecursive( templates fs.FS, ext string, nonRootTemplateNames bool, funcMap template.FuncMap) (*template.Template, error)
TemplateParseFSRecursive recursively parses all templates in the FS with the given extension. File paths are used as template names to support duplicate file names. Use nonRootTemplateNames to exclude root directory from template names (e.g. index.html instead of templates/index.html)
Types ¶
type Headers ¶
Headers is a map of string to string where the key is the key for the header And the value is the value for the header
type Response ¶
type Response struct { // StatusCode Status int // Content Type to writer ContentType string // Content to be written to the response writer Content io.Reader // Headers to be written to the response writer Headers Headers }
Response is a generic response object for our handlers
func HTML ¶
func HTML(status int, t *template.Template, template string, data interface{}, headers Headers) *Response
HTML renders an html template to a web response
func (*Response) Write ¶
func (response *Response) Write(rw http.ResponseWriter)
Write writes a response to an http.ResponseWriter
Click to show internal directories.
Click to hide internal directories.