Documentation
¶
Index ¶
- Constants
- Variables
- func BodyAsCSS(req *http.Request, res *string) error
- func BodyAsHTML(req *http.Request, res *string) error
- func BodyAsJSON(req *http.Request, objref any) error
- func BodyAsJavascript(req *http.Request, res *string) error
- func BodyAsText(req *http.Request, res *string) error
- func BodyAsXML(req *http.Request, objref any) error
- func GetContentFromRequest(req *http.Request, content Content) error
- func GetPaginationHeader(r *http.Request, count, limit, page *int) error
- func NewPath(path string, args ...ArgValue) string
- func NewRequest(method string, path string, body Content, args ...ArgValue) (*http.Request, error)
- func NewURL(path string, args ...ArgValue) string
- func PutPathArgsToCtx(req *http.Request, args ...ArgValue) *http.Request
- func ReadFromBody(req *http.Request, content Content) error
- func ServeContent(c Content, rw http.ResponseWriter) error
- func SetPaginationHeader(rw http.ResponseWriter, count, limit, page int)
- type Arg
- type ArgScanner
- type ArgType
- type ArgValue
- type Args
- type CSS
- type Content
- type Contexter
- type CookieArg
- type CoreContext
- func (m *CoreContext) BodyAsCSS(res *string) error
- func (m *CoreContext) BodyAsHTML(res *string) error
- func (m *CoreContext) BodyAsJSON(object_ref any) error
- func (m *CoreContext) BodyAsJavascript(res *string) error
- func (m *CoreContext) BodyAsText(res *string) error
- func (m *CoreContext) BodyAsXML(object_ref any) error
- func (m *CoreContext) GetPaginationHeader(count, limit, page *int) error
- func (e *CoreContext) HxRefreshOrRedirect(url string) error
- func (e *CoreContext) HxWantsPartial() bool
- func (e *CoreContext) IsHxBoosted() bool
- func (e *CoreContext) IsHxHistoryRestoreRequest() bool
- func (e *CoreContext) IsHxRequest() bool
- func (m *CoreContext) MovedPermanently(url string) error
- func (m *CoreContext) MovedTemporary(url string) error
- func (m *CoreContext) Redirect(url string) error
- func (e *CoreContext) Request() *http.Request
- func (e *CoreContext) ResponseWriter() http.ResponseWriter
- func (e *CoreContext) Route() Route
- func (m *CoreContext) Scan(targets ...any) error
- func (m *CoreContext) SendCSS(data string) error
- func (m *CoreContext) SendFormErrors(errMap errors.ErrMap) error
- func (m *CoreContext) SendHTML(data any) error
- func (e *CoreContext) SendHxRefresh() error
- func (m *CoreContext) SendJSON(data any) error
- func (m *CoreContext) SendJavaScript(data string) error
- func (m *CoreContext) SendText(data string) error
- func (m *CoreContext) SendXML(data any) error
- func (m *CoreContext) SetHeader(key, value string)
- func (m *CoreContext) SetPaginationHeader(count, limit, page int)
- func (m *CoreContext) Status(code int) error
- func (m *CoreContext) StatusHtmxCancelPolling() error
- func (m *CoreContext) StatusNotFound() error
- func (m *CoreContext) StatusOK() error
- 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) Set(a any) ArgValue
- func (p FormArg) Source() string
- func (p FormArg) String() FormArg
- func (p FormArg) Type() ArgType
- 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) Set(a any) ArgValue
- func (p FormArgOpt) Source() string
- func (p FormArgOpt) String() FormArgOpt
- func (p FormArgOpt) Type() ArgType
- func (p FormArgOpt) XML() FormArgOpt
- type HTML
- type HandlerFunc
- 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) Set(a any) ArgValue
- func (p QueryArg) Source() string
- func (p QueryArg) String() QueryArg
- func (p QueryArg) Type() ArgType
- 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) Set(a any) ArgValue
- func (p QueryArgOpt) Source() string
- func (p QueryArgOpt) String() QueryArgOpt
- func (p QueryArgOpt) Type() ArgType
- func (p QueryArgOpt) XML() QueryArgOpt
- type Route
- type RouteHandler
- func (r *RouteHandler[T]) Args() Args
- func (r *RouteHandler[T]) Call(payload Content, args ...ArgValue) (*http.Request, error)
- func (r *RouteHandler[T]) Do(fn func(ctx T) error) *RouteHandler[T]
- func (r *RouteHandler[T]) GetContent(response Content, args ...ArgValue) error
- func (r *RouteHandler[T]) GetContentWithPlayload(payload Content, response Content, args ...ArgValue) error
- func (r *RouteHandler[T]) HasHandler() bool
- func (r *RouteHandler[T]) Link(name string, argVals ...ArgValue) Link
- func (r *RouteHandler[T]) Method() string
- func (r *RouteHandler[T]) Mount(comp *Router[T])
- func (r *RouteHandler[T]) MountPath() string
- func (r *RouteHandler[T]) MustCall(payload Content, args ...ArgValue) *http.Request
- func (r *RouteHandler[T]) Path() string
- func (r *RouteHandler[T]) Scan(req *http.Request, targets ...any) error
- func (r *RouteHandler[T]) ServeHTTP(wr http.ResponseWriter, req *http.Request)
- func (r *RouteHandler[T]) URL(argVals ...ArgValue) string
- func (r *RouteHandler[T]) WithArgs(args ...Arg) *RouteHandler[T]
- type Router
- func (c *Router[T]) DELETE(localpath string) *RouteHandler[T]
- func (c *Router[T]) GET(localpath string) *RouteHandler[T]
- func (c *Router[T]) HEAD(localpath string) *RouteHandler[T]
- func (c *Router[T]) Mount(rt *router.Router, pathPrefix string)
- func (c *Router[T]) OPTIONS(localpath string) *RouteHandler[T]
- func (c *Router[T]) PATCH(localpath string) *RouteHandler[T]
- func (c *Router[T]) POST(localpath string) *RouteHandler[T]
- func (c *Router[T]) PUT(localpath string) *RouteHandler[T]
- func (c *Router[T]) Path() string
- func (c *Router[T]) SetErrorHandler(fn func(r Route, ctx T, err error) (continueHandling bool))
- func (c *Router[T]) SetVerbose() *Router[T]
- func (rt *Router[T]) SubRouter(name string, prefix string) *Router[T]
- func (rt *Router[T]) Use(fn func(next func(T) error) func(T) error) *Router[T]
- 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"
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 BodyAsJavascript ¶ added in v0.11.0
func GetContentFromRequest ¶ added in v0.11.0
func GetPaginationHeader ¶ added in v0.11.0
func NewRequest ¶
func PutPathArgsToCtx ¶ added in v0.11.0
func ServeContent ¶ added in v0.11.0
func ServeContent(c Content, rw http.ResponseWriter) error
func SetPaginationHeader ¶ added in v0.11.0
func SetPaginationHeader(rw http.ResponseWriter, count, limit, page int)
Types ¶
type ArgScanner ¶
type Contexter ¶ added in v0.11.0
type Contexter interface { Route() Route Request() *http.Request ResponseWriter() http.ResponseWriter }
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 CoreContext ¶ added in v0.11.0
type CoreContext struct {
// contains filtered or unexported fields
}
func NewCoreContext ¶ added in v0.11.0
func NewCoreContext(rt Route, rw http.ResponseWriter, req *http.Request) *CoreContext
func (*CoreContext) BodyAsCSS ¶ added in v0.11.0
func (m *CoreContext) BodyAsCSS(res *string) error
func (*CoreContext) BodyAsHTML ¶ added in v0.11.0
func (m *CoreContext) BodyAsHTML(res *string) error
func (*CoreContext) BodyAsJSON ¶ added in v0.11.0
func (m *CoreContext) BodyAsJSON(object_ref any) error
func (*CoreContext) BodyAsJavascript ¶ added in v0.11.0
func (m *CoreContext) BodyAsJavascript(res *string) error
func (*CoreContext) BodyAsText ¶ added in v0.11.0
func (m *CoreContext) BodyAsText(res *string) error
func (*CoreContext) BodyAsXML ¶ added in v0.11.0
func (m *CoreContext) BodyAsXML(object_ref any) error
func (*CoreContext) GetPaginationHeader ¶ added in v0.11.0
func (m *CoreContext) GetPaginationHeader(count, limit, page *int) error
func (*CoreContext) HxRefreshOrRedirect ¶ added in v0.11.0
func (e *CoreContext) HxRefreshOrRedirect(url string) error
func (*CoreContext) HxWantsPartial ¶ added in v0.11.0
func (e *CoreContext) HxWantsPartial() bool
func (*CoreContext) IsHxBoosted ¶ added in v0.11.0
func (e *CoreContext) IsHxBoosted() bool
func (*CoreContext) IsHxHistoryRestoreRequest ¶ added in v0.11.0
func (e *CoreContext) IsHxHistoryRestoreRequest() bool
func (*CoreContext) IsHxRequest ¶ added in v0.11.0
func (e *CoreContext) IsHxRequest() bool
func (*CoreContext) MovedPermanently ¶ added in v0.11.0
func (m *CoreContext) MovedPermanently(url string) error
func (*CoreContext) MovedTemporary ¶ added in v0.11.0
func (m *CoreContext) MovedTemporary(url string) error
func (*CoreContext) Redirect ¶ added in v0.11.0
func (m *CoreContext) Redirect(url string) error
func (*CoreContext) Request ¶ added in v0.11.0
func (e *CoreContext) Request() *http.Request
func (*CoreContext) ResponseWriter ¶ added in v0.11.0
func (e *CoreContext) ResponseWriter() http.ResponseWriter
func (*CoreContext) Route ¶ added in v0.11.0
func (e *CoreContext) Route() Route
func (*CoreContext) Scan ¶ added in v0.11.0
func (m *CoreContext) Scan(targets ...any) error
func (*CoreContext) SendCSS ¶ added in v0.11.0
func (m *CoreContext) SendCSS(data string) error
func (*CoreContext) SendFormErrors ¶ added in v0.11.0
func (m *CoreContext) SendFormErrors(errMap errors.ErrMap) error
func (*CoreContext) SendHTML ¶ added in v0.11.0
func (m *CoreContext) SendHTML(data any) error
func (*CoreContext) SendHxRefresh ¶ added in v0.11.0
func (e *CoreContext) SendHxRefresh() error
func (*CoreContext) SendJSON ¶ added in v0.11.0
func (m *CoreContext) SendJSON(data any) error
func (*CoreContext) SendJavaScript ¶ added in v0.11.0
func (m *CoreContext) SendJavaScript(data string) error
func (*CoreContext) SendText ¶ added in v0.11.0
func (m *CoreContext) SendText(data string) error
func (*CoreContext) SendXML ¶ added in v0.11.0
func (m *CoreContext) SendXML(data any) error
func (*CoreContext) SetHeader ¶ added in v0.11.0
func (m *CoreContext) SetHeader(key, value string)
func (*CoreContext) SetPaginationHeader ¶ added in v0.11.0
func (m *CoreContext) SetPaginationHeader(count, limit, page int)
func (*CoreContext) Status ¶ added in v0.11.0
func (m *CoreContext) Status(code int) error
func (*CoreContext) StatusHtmxCancelPolling ¶ added in v0.11.0
func (m *CoreContext) StatusHtmxCancelPolling() error
func (*CoreContext) StatusNotFound ¶ added in v0.11.0
func (m *CoreContext) StatusNotFound() error
func (*CoreContext) StatusOK ¶ added in v0.11.0
func (m *CoreContext) StatusOK() error
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) Set ¶ added in v0.7.0
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) String ¶
func (p FormArgOpt) String() FormArgOpt
func (FormArgOpt) XML ¶
func (p FormArgOpt) XML() FormArgOpt
type HandlerFunc ¶ added in v0.11.0
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) Set ¶ added in v0.7.0
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) String ¶
func (p QueryArgOpt) String() QueryArgOpt
func (QueryArgOpt) XML ¶
func (p QueryArgOpt) XML() QueryArgOpt
type Route ¶
type Route interface { Args() Args Method() string Link(name string, argVals ...ArgValue) Link URL(argVals ...ArgValue) string Path() string HasHandler() bool Call(body Content, args ...ArgValue) (*http.Request, error) MustCall(body Content, args ...ArgValue) *http.Request GetContent(response Content, args ...ArgValue) error GetContentWithPlayload(payload Content, response Content, args ...ArgValue) error Scan(req *http.Request, targets ...any) error }
type RouteHandler ¶ added in v0.11.0
type RouteHandler[T Contexter] struct { // contains filtered or unexported fields }
func (*RouteHandler[T]) Args ¶ added in v0.11.0
func (r *RouteHandler[T]) Args() Args
func (*RouteHandler[T]) Do ¶ added in v0.11.0
func (r *RouteHandler[T]) Do(fn func(ctx T) error) *RouteHandler[T]
func (*RouteHandler[T]) GetContent ¶ added in v0.11.0
func (r *RouteHandler[T]) GetContent(response Content, args ...ArgValue) error
func (*RouteHandler[T]) GetContentWithPlayload ¶ added in v0.11.0
func (r *RouteHandler[T]) GetContentWithPlayload(payload Content, response Content, args ...ArgValue) error
func (*RouteHandler[T]) HasHandler ¶ added in v0.11.0
func (r *RouteHandler[T]) HasHandler() bool
func (*RouteHandler[T]) Link ¶ added in v0.11.0
func (r *RouteHandler[T]) Link(name string, argVals ...ArgValue) Link
func (*RouteHandler[T]) Method ¶ added in v0.11.0
func (r *RouteHandler[T]) Method() string
func (*RouteHandler[T]) Mount ¶ added in v0.11.0
func (r *RouteHandler[T]) Mount(comp *Router[T])
func (*RouteHandler[T]) MountPath ¶ added in v0.11.0
func (r *RouteHandler[T]) MountPath() string
func (*RouteHandler[T]) MustCall ¶ added in v0.11.0
func (r *RouteHandler[T]) MustCall(payload Content, args ...ArgValue) *http.Request
MustCall is like Call and panics on errors
func (*RouteHandler[T]) Path ¶ added in v0.11.0
func (r *RouteHandler[T]) Path() string
func (*RouteHandler[T]) Scan ¶ added in v0.11.0
func (r *RouteHandler[T]) Scan(req *http.Request, targets ...any) error
func (*RouteHandler[T]) ServeHTTP ¶ added in v0.11.0
func (r *RouteHandler[T]) ServeHTTP(wr http.ResponseWriter, req *http.Request)
func (*RouteHandler[T]) URL ¶ added in v0.11.0
func (r *RouteHandler[T]) URL(argVals ...ArgValue) string
panics when arg is missing
func (*RouteHandler[T]) WithArgs ¶ added in v0.11.0
func (r *RouteHandler[T]) WithArgs(args ...Arg) *RouteHandler[T]
type Router ¶ added in v0.3.0
type Router[T Contexter] struct { Name string Routes []*RouteHandler[T] // contains filtered or unexported fields }
func (*Router[T]) DELETE ¶ added in v0.3.0
func (c *Router[T]) DELETE(localpath string) *RouteHandler[T]
func (*Router[T]) GET ¶ added in v0.3.0
func (c *Router[T]) GET(localpath string) *RouteHandler[T]
func (*Router[T]) HEAD ¶ added in v0.3.0
func (c *Router[T]) HEAD(localpath string) *RouteHandler[T]
func (*Router[T]) OPTIONS ¶ added in v0.3.0
func (c *Router[T]) OPTIONS(localpath string) *RouteHandler[T]
func (*Router[T]) PATCH ¶ added in v0.3.0
func (c *Router[T]) PATCH(localpath string) *RouteHandler[T]
func (*Router[T]) POST ¶ added in v0.3.0
func (c *Router[T]) POST(localpath string) *RouteHandler[T]
func (*Router[T]) PUT ¶ added in v0.3.0
func (c *Router[T]) PUT(localpath string) *RouteHandler[T]
func (*Router[T]) SetErrorHandler ¶ added in v0.3.0
func (*Router[T]) SetVerbose ¶ added in v0.9.0
Source Files
¶
Click to show internal directories.
Click to hide internal directories.