Documentation
¶
Index ¶
- Constants
- Variables
- func MovedPermanently(url string) statusRedirect
- func MovedTemporary(url string) statusRedirect
- func NewPath(path string, args ...ArgValue) string
- func NewURL(path string, args ...ArgValue) string
- func Redirect(url string) statusRedirect
- type Arg
- type ArgScanner
- type ArgType
- type ArgValue
- type Args
- type CSS
- type Content
- type CookieArg
- type FormArg
- func (p FormArg) Bool() FormArg
- func (p FormArg) Float() FormArg
- func (p FormArg) Int() FormArg
- func (p FormArg) IsRequired() bool
- func (p FormArg) JSON() FormArg
- func (p FormArg) Name() string
- func (p FormArg) ReadValue(req *http.Request) (string, error)
- func (p FormArg) Source() string
- func (p FormArg) String() FormArg
- func (p FormArg) Type() ArgType
- func (p FormArg) Value(a any) ArgValue
- func (p FormArg) XML() FormArg
- type FormArgOpt
- func (p FormArgOpt) Bool() FormArgOpt
- func (p FormArgOpt) Float() FormArgOpt
- func (p FormArgOpt) Int() FormArgOpt
- func (p FormArgOpt) IsRequired() bool
- func (p FormArgOpt) JSON() FormArgOpt
- func (p FormArgOpt) Name() string
- func (p FormArgOpt) ReadValue(req *http.Request) (string, error)
- func (p FormArgOpt) Source() string
- func (p FormArgOpt) String() FormArgOpt
- func (p FormArgOpt) Type() ArgType
- func (p FormArgOpt) Value(a any) ArgValue
- func (p FormArgOpt) XML() FormArgOpt
- type HTML
- type HeaderArg
- type JSON
- type JavaScript
- type Link
- type PathArg
- type QueryArg
- func (p QueryArg) Bool() QueryArg
- func (p QueryArg) Float() QueryArg
- func (p QueryArg) Int() QueryArg
- func (p QueryArg) IsRequired() bool
- func (p QueryArg) JSON() QueryArg
- func (p QueryArg) Name() string
- func (p QueryArg) ReadValue(req *http.Request) (string, error)
- func (p QueryArg) Source() string
- func (p QueryArg) String() QueryArg
- func (p QueryArg) Type() ArgType
- func (p QueryArg) Value(a any) ArgValue
- func (p QueryArg) XML() QueryArg
- type QueryArgOpt
- func (p QueryArgOpt) Bool() QueryArgOpt
- func (p QueryArgOpt) Float() QueryArgOpt
- func (p QueryArgOpt) Int() QueryArgOpt
- func (p QueryArgOpt) IsRequired() bool
- func (p QueryArgOpt) JSON() QueryArgOpt
- func (p QueryArgOpt) Name() string
- func (p QueryArgOpt) ReadValue(req *http.Request) (string, error)
- func (p QueryArgOpt) Source() string
- func (p QueryArgOpt) String() QueryArgOpt
- func (p QueryArgOpt) Type() ArgType
- func (p QueryArgOpt) Value(a any) ArgValue
- func (p QueryArgOpt) XML() QueryArgOpt
- type Request
- func (req *Request) BodyAsCSS(res *string) error
- func (req *Request) BodyAsHTML(res *string) error
- func (req *Request) BodyAsJSON(objref any) error
- func (req *Request) BodyAsJavascript(res *string) error
- func (req *Request) BodyAsText(res *string) error
- func (req *Request) BodyAsXML(objref any) error
- func (r *Request) GetPaginationHeader(count, limit, page *int) error
- func (r *Request) HxWantsPartial() bool
- func (r *Request) IsHxBoosted() bool
- func (r *Request) IsHxHistoryRestoreRequest() bool
- func (r *Request) IsHxRequest() bool
- func (req *Request) PutPathArgsToCtx(args ...ArgValue)
- func (req *Request) ReadFromBody(content Content) error
- func (r *Request) Scan(targets ...any) error
- func (r *Request) SetPaginationHeader(count, limit, page int)
- type Route
- func (r *Route[T]) Call(body Content, args ...ArgValue) (Content, error)
- func (r *Route[T]) Do(fn func(ctx T, req *Request) (Content, error)) *Route[T]
- func (r *Route[T]) HasHandler() bool
- func (r *Route[T]) Link(name string, argVals ...ArgValue) Link
- func (r *Route[T]) Method() string
- func (r *Route[T]) Mount(comp *Router[T])
- func (r *Route[T]) MountPath() string
- func (r *Route[T]) Path() string
- func (r *Route[T]) ServeHTTP(wr http.ResponseWriter, req *http.Request)
- func (r *Route[T]) URL(argVals ...ArgValue) string
- func (r *Route[T]) WithArgs(args ...Arg) *Route[T]
- type Router
- func (c *Router[T]) DELETE(localpath string, pathArgs ...PathArg) *Route[T]
- func (c *Router[T]) GET(localpath string, pathArgs ...PathArg) *Route[T]
- func (c *Router[T]) HEAD(localpath string, pathArgs ...PathArg) *Route[T]
- func (c *Router[T]) HandleError(r *Route[T], req *Request, wr http.ResponseWriter, err error) (writeBody bool)
- func (c *Router[T]) Mount(rt *router.Router, pathPrefix string)
- func (c *Router[T]) OPTIONS(localpath string, pathArgs ...PathArg) *Route[T]
- func (c *Router[T]) PATCH(localpath string, pathArgs ...PathArg) *Route[T]
- func (c *Router[T]) POST(localpath string, pathArgs ...PathArg) *Route[T]
- func (c *Router[T]) PUT(localpath string, pathArgs ...PathArg) *Route[T]
- func (c *Router[T]) Path() string
- func (c *Router[T]) ServeContent(r *Route[T], content Content, wr http.ResponseWriter, req *Request)
- func (c *Router[T]) SetErrorHandler(...)
- func (c *Router[T]) SetLayouter(fn func(r *Route[T], req *Request, inner html.Htmler) html.Html)
- func (c *Router[T]) Use(fns ...func(http.Handler) http.Handler)
- type Status
- type Text
- type XML
Constants ¶
View Source
const CookieSrc = "Cookie"
View Source
const FormSrc = "Form"
View Source
const HeaderSrc = "Header"
View Source
const PathSrc = "Path"
View Source
const QuerySrc = "Query"
View Source
const StatusOK = Status(200)
Variables ¶
View Source
var ( StringArg = ArgType("string") IntArg = ArgType("int") FloatArg = ArgType("float") BoolArg = ArgType("bool") JSONArg = ArgType("json") XMLArg = ArgType("xml") )
View Source
var ( ErrNotFound = errors.Error("not found: %v") ErrUnexpected = errors.Error("unexpected: %v") ErrInvalidType = errors.Error("invalid type: %T (expected %T)") ErrMissing = errors.Error("missing: %s") ErrForbidden = errors.Error("forbidden: %s") )
View Source
var ( ErrWrongContentType = errors.Error("wrong content type: %s (expected %s)") ErrValidation = errors.Error("validation error: %w") )
View Source
var ( ErrArgNotFound = errors.Error("argument with name %q could not be found") ErrArgExists = errors.Error("argument with name %q already exists") ErrArgMissing = errors.Error("missing argument %q of source %q") ErrArgNotInRequest = errors.Error("argument %q of type %s not in request") ErrArgUnknown = errors.Error("unknown argument %q given") ErrArgInvalidType = errors.Error("invalid type for argument %s: %T (expected %T)") )
View Source
var ( ErrPathArgNotRegistered = errors.Error("path argument %q from path string %q not registered") ErrPathArgRegisteredWithWrongType = errors.Error("path argument %q from path string %q registered with wrong path type (%q)") ErrPathArgRegisteredNotInPath = errors.Error("path argument %q registered, but not inside path string %q") )
View Source
var ( ErrClientRequest = errors.Error("error while making a request as a client: %w") ErrFormArgsAndBody = errors.Error("form arguments (%#v) and a body can't be passed at the same time") ErrBodyNotAllowedForMethod = errors.Error("transmitting a form for method %s is not allowed") )
View Source
var (
ErrFormArg = errors.Error("form argument %q given")
)
View Source
var HeaderArgPaginationCount = NewHeaderArg("Pagination-Count")
View Source
var HeaderArgPaginationLimit = NewHeaderArg("Pagination-Limit")
View Source
var HeaderArgPaginationPage = NewHeaderArg("Pagination-Page")
Functions ¶
func MovedPermanently ¶
func MovedPermanently(url string) statusRedirect
MovedPermanently e.g. whole webpage moved
func MovedTemporary ¶
func MovedTemporary(url string) statusRedirect
MovedTemporary e.g. for maintenance
Types ¶
type ArgScanner ¶
type CookieArg ¶ added in v0.2.0
type CookieArg struct {
// contains filtered or unexported fields
}
func NewCookieArg ¶ added in v0.2.0
func (CookieArg) IsRequired ¶ added in v0.2.0
type FormArg ¶
type FormArg struct {
// contains filtered or unexported fields
}
func NewFormArg ¶
func (FormArg) IsRequired ¶
func (p FormArg) IsRequired() bool
type FormArgOpt ¶
type FormArgOpt struct {
FormArg
}
func NewFormArgOpt ¶
func NewFormArgOpt(name string) FormArgOpt
func (FormArgOpt) Bool ¶
func (p FormArgOpt) Bool() FormArgOpt
func (FormArgOpt) Float ¶
func (p FormArgOpt) Float() FormArgOpt
func (FormArgOpt) Int ¶
func (p FormArgOpt) Int() FormArgOpt
func (FormArgOpt) IsRequired ¶
func (p FormArgOpt) IsRequired() bool
func (FormArgOpt) JSON ¶
func (p FormArgOpt) JSON() FormArgOpt
func (FormArgOpt) String ¶
func (p FormArgOpt) String() FormArgOpt
func (FormArgOpt) Value ¶
here is a hack: we allow the path arguments to be set via string also (which is related), we never have a type for PathArgs and therefor don't check, when we want to parse them
func (FormArgOpt) XML ¶
func (p FormArgOpt) XML() FormArgOpt
type HeaderArg ¶
type HeaderArg struct {
// contains filtered or unexported fields
}
func NewHeaderArg ¶
func (HeaderArg) IsRequired ¶
type JavaScript ¶
type JavaScript struct {
Data string
}
func NewJavaScript ¶ added in v0.1.9
func NewJavaScript(data string) *JavaScript
func (JavaScript) ContentType ¶
func (s JavaScript) ContentType() string
type PathArg ¶
type PathArg struct {
// contains filtered or unexported fields
}
func NewPathArg ¶
func (PathArg) IsRequired ¶
func (p PathArg) IsRequired() bool
type QueryArg ¶
type QueryArg struct {
// contains filtered or unexported fields
}
func NewQueryArg ¶
func (QueryArg) IsRequired ¶
func (p QueryArg) IsRequired() bool
type QueryArgOpt ¶
type QueryArgOpt struct {
QueryArg
}
func NewQueryArgOpt ¶
func NewQueryArgOpt(name string) QueryArgOpt
func (QueryArgOpt) Bool ¶
func (p QueryArgOpt) Bool() QueryArgOpt
func (QueryArgOpt) Float ¶
func (p QueryArgOpt) Float() QueryArgOpt
func (QueryArgOpt) Int ¶
func (p QueryArgOpt) Int() QueryArgOpt
func (QueryArgOpt) IsRequired ¶
func (p QueryArgOpt) IsRequired() bool
func (QueryArgOpt) JSON ¶
func (p QueryArgOpt) JSON() QueryArgOpt
func (QueryArgOpt) String ¶
func (p QueryArgOpt) String() QueryArgOpt
func (QueryArgOpt) Value ¶
here is a hack: we allow the path arguments to be set via string also (which is related), we never have a type for PathArgs and therefor don't check, when we want to parse them
func (QueryArgOpt) XML ¶
func (p QueryArgOpt) XML() QueryArgOpt
type Request ¶
func NewRequest ¶
func (*Request) BodyAsHTML ¶
func (*Request) BodyAsJSON ¶
func (*Request) BodyAsJavascript ¶
func (*Request) BodyAsText ¶
func (*Request) GetPaginationHeader ¶
func (*Request) HxWantsPartial ¶ added in v0.1.10
func (*Request) IsHxBoosted ¶ added in v0.1.10
func (*Request) IsHxHistoryRestoreRequest ¶ added in v0.1.10
func (*Request) IsHxRequest ¶ added in v0.1.10
func (*Request) PutPathArgsToCtx ¶
func (*Request) ReadFromBody ¶
func (*Request) SetPaginationHeader ¶
type Route ¶
type Route[T any] struct { // contains filtered or unexported fields }
func (*Route[T]) HasHandler ¶
func (*Route[T]) ServeHTTP ¶
func (r *Route[T]) ServeHTTP(wr http.ResponseWriter, req *http.Request)
type Router ¶ added in v0.3.0
type Router[T any] struct { Name string Routes []*Route[T] // contains filtered or unexported fields }
func (*Router[T]) HandleError ¶ added in v0.3.0
func (*Router[T]) ServeContent ¶ added in v0.3.0
func (*Router[T]) SetErrorHandler ¶ added in v0.3.0
func (*Router[T]) SetLayouter ¶ added in v0.3.0
Source Files
¶
Click to show internal directories.
Click to hide internal directories.