web

package
v0.13.66 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2025 License: BSD-3-Clause Imports: 25 Imported by: 6

Documentation

Index

Constants

View Source
const (
	HeaderPaginationCount = "Pagination-Count"
	HeaderPaginationPage  = "Pagination-Page"
	HeaderPaginationLimit = "Pagination-Limit"
)

Variables

View Source
var (
	SrcFromQuery  = ArgSource("FromQuery")
	SrcFromForm   = ArgSource("FromForm")
	SrcFromPath   = ArgSource("FromPath")
	SrcFromHeader = ArgSource("FromHeader")
	SrcFromCookie = ArgSource("FromCookie")
)
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")
)

Functions

func BodyAsCSS

func BodyAsCSS(req *http.Request, res *string) error

func BodyAsHTML

func BodyAsHTML(req *http.Request, res *string) error

func BodyAsJSON

func BodyAsJSON(req *http.Request, objref any) error

func BodyAsJavascript

func BodyAsJavascript(req *http.Request, res *string) error

func BodyAsText

func BodyAsText(req *http.Request, res *string) error

func BodyAsXML

func BodyAsXML(req *http.Request, objref any) error

func CheckRoute

func CheckRoute[R routeCheck[R]](r R) bool

the check is done via the routeCheck and this is compilation time

func GetContentFromRequest

func GetContentFromRequest(req *http.Request, content Content) error

func GetPaginationHeader

func GetPaginationHeader(r *http.Request, count, limit, page *int) error

func NewPath

func NewPath(path string, args ...Argument) string

func NewRequest

func NewRequest(method string, path string, body Content, _args ...Argument) (*http.Request, error)

func NewURL

func NewURL(path string, _args ...Argument) string

func PutPathArgsToCtx

func PutPathArgsToCtx(req *http.Request, _args ...Argument) *http.Request

func ReadFromBody

func ReadFromBody(req *http.Request, content Content) error

func ServeContent

func ServeContent(c Content, rw http.ResponseWriter) error

func SetPaginationHeader

func SetPaginationHeader(rw http.ResponseWriter, count, limit, page int)

func SplitArg added in v0.13.4

func SplitArg[C ArgValueTypesCore](argVal string, val *value.Var[[]C]) (err error)

func StringToA

func StringToA[T ArgValueTypes](s string) (T, error)

func StringsToA added in v0.13.4

func StringsToA[T ArgValueTypesCore](s []string) ([]T, error)

Types

type Arg

type Arg interface {
	IsSet() bool
	IsRequired() bool
	Source() ArgSource
	Name() string
	Value() any
	Err() error
}

type ArgScanner

type ArgScanner interface {
	Scan(targets ...any) error
}

type ArgSource

type ArgSource string

type ArgValueTypes

type ArgValueTypes interface {
	ArgValueTypesCore |
		[]string | []int | []uint | []bool | []float64 | []float32 |
		map[string]string | map[string]any
}

type ArgValueTypesCore added in v0.13.4

type ArgValueTypesCore interface {
	string | []byte |
		int | int8 | int16 | int32 | int64 |
		uint | uint8 | uint16 | uint32 | uint64 |
		float64 | float32 |
		bool
}

type Argument

type Argument interface {
	Arg
	ReadValue(req *http.Request)
	SetName(string)
	AddErr(error)
	VarValue() value.Value
}

type Arguments

type Arguments []Argument

func (Arguments) Vars

func (a Arguments) Vars() []value.Value

type CSS

type CSS struct {
	Data string
}

func NewCSS

func NewCSS(data string) *CSS

func (CSS) ContentType

func (s CSS) ContentType() string

func (*CSS) ReadFrom

func (t *CSS) ReadFrom(rd io.Reader) error

func (CSS) WriteTo

func (t CSS) WriteTo(wr io.Writer) error

type Content

type Content interface {
	ContentType() string
	WriteTo(w io.Writer) error
	ReadFrom(rd io.Reader) error
}

type Contexter

type Contexter interface {
	Route() Route
	Request() *http.Request
	ResponseWriter() http.ResponseWriter
}

type CookieArg

type CookieArg[T ArgValueTypes] struct {
	// contains filtered or unexported fields
}

func NewCookieArg

func NewCookieArg[T ArgValueTypes](name string) CookieArg[T]

func NewCookieArgOpt

func NewCookieArgOpt[T ArgValueTypes](name string) CookieArg[T]

func (CookieArg) IsRequired

func (b CookieArg) IsRequired() bool

func (CookieArg) IsSet

func (b CookieArg) IsSet() bool

func (CookieArg[T]) New

func (q CookieArg[T]) New() *CookieArg[T]

func (*CookieArg[T]) ReadValue

func (q *CookieArg[T]) ReadValue(req *http.Request)

func (*CookieArg[T]) Set

func (q *CookieArg[T]) Set(s T) *CookieArg[T]

func (*CookieArg) SetName

func (b *CookieArg) SetName(name string)

func (CookieArg) Source

func (b CookieArg) Source() ArgSource

func (*CookieArg) VarValue

func (b *CookieArg) VarValue() value.Value

type CoreContext

type CoreContext struct {
	IsHandled       bool // the route was already been handled
	IsHeaderWritten bool
	Debug           bool // debug/development mode
	// contains filtered or unexported fields
}

func NewCoreContext

func NewCoreContext(rt Route, rw http.ResponseWriter, req *http.Request) *CoreContext

func (*CoreContext) BodyAsCSS

func (m *CoreContext) BodyAsCSS(res *string) error

func (*CoreContext) BodyAsHTML

func (m *CoreContext) BodyAsHTML(res *string) error

func (*CoreContext) BodyAsJSON

func (m *CoreContext) BodyAsJSON(object_ref any) error

func (*CoreContext) BodyAsJavascript

func (m *CoreContext) BodyAsJavascript(res *string) error

func (*CoreContext) BodyAsText

func (m *CoreContext) BodyAsText(res *string) error

func (*CoreContext) BodyAsXML

func (m *CoreContext) BodyAsXML(object_ref any) error

func (*CoreContext) GetPaginationHeader

func (m *CoreContext) GetPaginationHeader(count, limit, page *int) error

func (*CoreContext) Header

func (c *CoreContext) Header() http.Header

func (*CoreContext) HxRefreshOrRedirect

func (e *CoreContext) HxRefreshOrRedirect(url string) error

func (*CoreContext) HxWantsPartial

func (e *CoreContext) HxWantsPartial() bool

func (*CoreContext) IsHxBoosted

func (e *CoreContext) IsHxBoosted() bool

func (*CoreContext) IsHxHistoryRestoreRequest

func (e *CoreContext) IsHxHistoryRestoreRequest() bool

func (*CoreContext) IsHxRequest

func (e *CoreContext) IsHxRequest() bool

func (*CoreContext) Log

func (c *CoreContext) Log(msg string)

func (*CoreContext) LogErr

func (c *CoreContext) LogErr(err error)

func (*CoreContext) MovedPermanently

func (m *CoreContext) MovedPermanently(url string) error

func (*CoreContext) MovedTemporary

func (m *CoreContext) MovedTemporary(url string) error

func (*CoreContext) Redirect

func (m *CoreContext) Redirect(url string) error

func (*CoreContext) Request

func (e *CoreContext) Request() *http.Request

func (*CoreContext) ResponseWriter

func (e *CoreContext) ResponseWriter() http.ResponseWriter

func (*CoreContext) Route

func (e *CoreContext) Route() Route

func (*CoreContext) SendArgErrs

func (c *CoreContext) SendArgErrs(targets ...Argument) (hadErrors bool)

func (*CoreContext) SendCSS

func (m *CoreContext) SendCSS(data string) error

func (*CoreContext) SendErr

func (c *CoreContext) SendErr(err error) (hadErrors bool)

func (*CoreContext) SendErrForbidden added in v0.13.60

func (c *CoreContext) SendErrForbidden()

func (*CoreContext) SendErrInvalidData

func (c *CoreContext) SendErrInvalidData(msg string)

func (*CoreContext) SendErrNotFound

func (c *CoreContext) SendErrNotFound(msg string)

func (*CoreContext) SendErrorMap added in v0.13.1

func (c *CoreContext) SendErrorMap(m map[string]string) bool

func (*CoreContext) SendFormErrs

func (c *CoreContext) SendFormErrs(generalErr error, formvals ...value.Value) (hadErrors bool)

func (*CoreContext) SendHTML

func (m *CoreContext) SendHTML(data any) error

func (*CoreContext) SendHxRefresh

func (e *CoreContext) SendHxRefresh() error

func (*CoreContext) SendHxTrigger added in v0.13.60

func (e *CoreContext) SendHxTrigger(what string) error

func (*CoreContext) SendJSON

func (m *CoreContext) SendJSON(data any) error

func (*CoreContext) SendJavaScript

func (m *CoreContext) SendJavaScript(data string) error

func (*CoreContext) SendText

func (m *CoreContext) SendText(data string) error

func (*CoreContext) SendXML

func (m *CoreContext) SendXML(data any) error

func (*CoreContext) SetHeader

func (m *CoreContext) SetHeader(key, value string)

func (*CoreContext) SetPaginationHeader

func (m *CoreContext) SetPaginationHeader(count, limit, page int)

func (*CoreContext) Status

func (m *CoreContext) Status(code int) error

func (*CoreContext) StatusHtmxCancelPolling

func (m *CoreContext) StatusHtmxCancelPolling() error

func (*CoreContext) StatusNotFound

func (m *CoreContext) StatusNotFound() error

func (*CoreContext) StatusOK

func (m *CoreContext) StatusOK() error

func (*CoreContext) Write

func (c *CoreContext) Write(bt []byte) (int, error)

func (*CoreContext) WriteHeader

func (c *CoreContext) WriteHeader(statusCode int)

type FormArg

type FormArg[T ArgValueTypes] struct {
	// contains filtered or unexported fields
}

func NewFormArg

func NewFormArg[T ArgValueTypes](name string) FormArg[T]

func NewFormArgOpt

func NewFormArgOpt[T ArgValueTypes](name string) FormArg[T]

func (FormArg) IsRequired

func (b FormArg) IsRequired() bool

func (FormArg) IsSet

func (b FormArg) IsSet() bool

func (FormArg[T]) New

func (q FormArg[T]) New() *FormArg[T]

func (FormArg[T]) Position added in v0.13.21

func (q FormArg[T]) Position() FormArgPos[T]

func (*FormArg[T]) ReadValue

func (q *FormArg[T]) ReadValue(req *http.Request)

func (*FormArg[T]) Set

func (q *FormArg[T]) Set(s T) *FormArg[T]

func (*FormArg) SetName

func (b *FormArg) SetName(name string)

func (FormArg) Source

func (b FormArg) Source() ArgSource

func (*FormArg) VarValue

func (b *FormArg) VarValue() value.Value

type FormArgPos added in v0.13.22

type FormArgPos[T ArgValueTypes] struct {
	FormArg[T]
	// contains filtered or unexported fields
}

func (*FormArgPos[T]) Field added in v0.13.23

func (q *FormArgPos[T]) Field() string

func (FormArgPos) IsRequired added in v0.13.22

func (b FormArgPos) IsRequired() bool

func (FormArgPos) IsSet added in v0.13.22

func (b FormArgPos) IsSet() bool

func (*FormArgPos[T]) Name added in v0.13.22

func (q *FormArgPos[T]) Name() string

func (*FormArgPos[T]) Set added in v0.13.22

func (q *FormArgPos[T]) Set(v T) *FormArgPos[T]

func (*FormArgPos) SetName added in v0.13.22

func (b *FormArgPos) SetName(name string)

func (FormArgPos) Source added in v0.13.22

func (b FormArgPos) Source() ArgSource

func (*FormArgPos[T]) String added in v0.13.22

func (q *FormArgPos[T]) String() string

func (*FormArgPos) VarValue added in v0.13.22

func (b *FormArgPos) VarValue() value.Value

func (*FormArgPos[T]) WriteTo added in v0.13.22

func (q *FormArgPos[T]) WriteTo(wr io.Writer) (int64, error)

type HTML

type HTML struct {
	Data string
}

func NewHTML

func NewHTML(data any) *HTML

func (HTML) ContentType

func (s HTML) ContentType() string

func (HTML) HTML added in v0.13.32

func (h HTML) HTML() html.HTML

func (*HTML) ReadFrom

func (t *HTML) ReadFrom(rd io.Reader) error

func (HTML) WriteTo

func (t HTML) WriteTo(wr io.Writer) error

type HandlerFunc

type HandlerFunc[T Contexter] func(T)

type HeaderArg

type HeaderArg[T ArgValueTypes] struct {
	// contains filtered or unexported fields
}

func NewHeaderArg

func NewHeaderArg[T ArgValueTypes](name string) HeaderArg[T]

func NewHeaderArgOpt

func NewHeaderArgOpt[T ArgValueTypes](name string) HeaderArg[T]

func (HeaderArg) IsRequired

func (b HeaderArg) IsRequired() bool

func (HeaderArg) IsSet

func (b HeaderArg) IsSet() bool

func (HeaderArg[T]) New

func (q HeaderArg[T]) New() *HeaderArg[T]

func (*HeaderArg[T]) ReadValue

func (q *HeaderArg[T]) ReadValue(req *http.Request)

func (*HeaderArg[T]) Set

func (q *HeaderArg[T]) Set(s T) *HeaderArg[T]

func (*HeaderArg) SetName

func (b *HeaderArg) SetName(name string)

func (HeaderArg) Source

func (b HeaderArg) Source() ArgSource

func (*HeaderArg) VarValue

func (b *HeaderArg) VarValue() value.Value

type JSON

type JSON struct {
	Data any
}

func NewJSON

func NewJSON(data any) *JSON

func (JSON) ContentType

func (s JSON) ContentType() string

func (*JSON) ReadFrom

func (s *JSON) ReadFrom(rd io.Reader) error

func (*JSON) WriteTo

func (s *JSON) WriteTo(wr io.Writer) error

type JavaScript

type JavaScript struct {
	Data string
}

func NewJavaScript

func NewJavaScript(data string) *JavaScript

func (JavaScript) ContentType

func (s JavaScript) ContentType() string

func (*JavaScript) ReadFrom

func (t *JavaScript) ReadFrom(rd io.Reader) error

func (JavaScript) WriteTo

func (t JavaScript) WriteTo(wr io.Writer) error
type Link struct {
	URL   string
	Label string
	// contains filtered or unexported fields
}

Link is a structure that might be a htmx link or a normal link it might manifest as a href or as a form the constructor or the recipient might set the label, the htmx status or the target. however the recipient (view) decides, if it is to be used as a href or as a form

func NewLinkDELETE added in v0.13.35

func NewLinkDELETE(url string) *Link

func NewLinkGET added in v0.13.35

func NewLinkGET(url string) *Link

func NewLinkPATCH added in v0.13.35

func NewLinkPATCH(url string) *Link

func NewLinkPOST added in v0.13.35

func NewLinkPOST(url string) *Link

func NewLinkPUT added in v0.13.35

func NewLinkPUT(url string) *Link

func (Link) AHref

func (c Link) AHref() *html.Element

func (Link) Button added in v0.13.32

func (c Link) Button() *html.Element

func (Link) Form added in v0.13.31

func (c Link) Form() *html.Element

Label is ignored in this case and must be added by the caller, if necessary

func (Link) HxApply added in v0.13.32

func (c Link) HxApply(el *html.Element) *html.Element

HxApply adds hx properties to the given element and panics, if Link is no HTMX Link. Label is not used in this case and must be applied from the caller

func (Link) IsGET added in v0.13.32

func (c Link) IsGET() bool

func (Link) IsHx added in v0.13.32

func (c Link) IsHx() bool

func (Link) Method added in v0.13.32

func (c Link) Method() string

func (*Link) SetHx added in v0.13.32

func (c *Link) SetHx() *Link

func (*Link) SetHxNoPushURL added in v0.13.32

func (c *Link) SetHxNoPushURL() *Link

func (*Link) SetHxPushURL added in v0.13.32

func (c *Link) SetHxPushURL() *Link

func (*Link) SetHxSwap added in v0.13.32

func (c *Link) SetHxSwap(swap string) *Link

func (*Link) SetHxTarget added in v0.13.32

func (c *Link) SetHxTarget(targetSelector string) *Link

func (*Link) SetHxTrigger added in v0.13.32

func (c *Link) SetHxTrigger(trigger string) *Link

func (*Link) SetLabel added in v0.13.31

func (c *Link) SetLabel(name string) *Link

type PathArg

type PathArg[T ArgValueTypes] struct {
	// contains filtered or unexported fields
}

func NewPathArg

func NewPathArg[T ArgValueTypes](name string) PathArg[T]

func (PathArg) IsRequired

func (b PathArg) IsRequired() bool

func (PathArg) IsSet

func (b PathArg) IsSet() bool

func (PathArg[T]) New

func (q PathArg[T]) New() *PathArg[T]

func (*PathArg[T]) ReadValue

func (q *PathArg[T]) ReadValue(req *http.Request)

func (*PathArg[T]) Set

func (q *PathArg[T]) Set(s T) *PathArg[T]

func (*PathArg) SetName

func (b *PathArg) SetName(name string)

func (PathArg) Source

func (b PathArg) Source() ArgSource

func (*PathArg) VarValue

func (b *PathArg) VarValue() value.Value

type QueryArg

type QueryArg[T ArgValueTypes] struct {
	// contains filtered or unexported fields
}

func NewQueryArg

func NewQueryArg[T ArgValueTypes](name string) QueryArg[T]

func NewQueryArgOpt

func NewQueryArgOpt[T ArgValueTypes](name string) QueryArg[T]

func (QueryArg) IsRequired

func (b QueryArg) IsRequired() bool

func (QueryArg) IsSet

func (b QueryArg) IsSet() bool

func (QueryArg[T]) New

func (q QueryArg[T]) New() *QueryArg[T]

New() returns a new copy which we need within the handler

func (*QueryArg[T]) ReadValue

func (q *QueryArg[T]) ReadValue(req *http.Request)

func (*QueryArg[T]) Set

func (q *QueryArg[T]) Set(s T) *QueryArg[T]

func (*QueryArg) SetName

func (b *QueryArg) SetName(name string)

func (QueryArg) Source

func (b QueryArg) Source() ArgSource

func (*QueryArg) VarValue

func (b *QueryArg) VarValue() value.Value

type Route

type Route interface {
	Args() []Arg
	Method() string
	URL(argVals ...Argument) string
	Link(argVals ...Argument) (c *Link)
	Path() string
	HasHandler() bool
	Call(body Content, args ...Argument) (*http.Response, error)
	MustCall(body Content, args ...Argument) *http.Response
	GetContent(response Content, args ...Argument) error
	GetContentWithPlayload(payload Content, response Content, args ...Argument) error

	HxGetContent(response Content, args ...Argument) error
	HxGetContentWithPlayload(payload Content, response Content, args ...Argument) error
	HxCall(payload Content, _args ...Argument) (*http.Response, error)
	HxMustCall(payload Content, args ...Argument) *http.Response

	Scan(req *http.Request, targets ...Argument)
}

type RouteHandler

type RouteHandler[T Contexter] struct {
	// contains filtered or unexported fields
}

func (*RouteHandler[T]) Args

func (r *RouteHandler[T]) Args() []Arg

func (*RouteHandler[T]) Call

func (r *RouteHandler[T]) Call(payload Content, _args ...Argument) (*http.Response, error)

func (*RouteHandler[T]) CallWithHeader added in v0.13.32

func (r *RouteHandler[T]) CallWithHeader(payload Content, headers http.Header, _args ...Argument) (*http.Response, error)

func (*RouteHandler[T]) Do

func (r *RouteHandler[T]) Do(fn func(ctx T)) *RouteHandler[T]

func (*RouteHandler[T]) GetContent

func (r *RouteHandler[T]) GetContent(response Content, args ...Argument) error

func (*RouteHandler[T]) GetContentWithPlayload

func (r *RouteHandler[T]) GetContentWithPlayload(payload Content, response Content, args ...Argument) error

func (*RouteHandler[T]) HasHandler

func (r *RouteHandler[T]) HasHandler() bool

func (*RouteHandler[T]) HxCall added in v0.13.32

func (r *RouteHandler[T]) HxCall(payload Content, _args ...Argument) (*http.Response, error)

func (*RouteHandler[T]) HxGetContent added in v0.13.32

func (r *RouteHandler[T]) HxGetContent(response Content, args ...Argument) error

func (*RouteHandler[T]) HxGetContentWithPlayload added in v0.13.32

func (r *RouteHandler[T]) HxGetContentWithPlayload(payload Content, response Content, args ...Argument) error

func (*RouteHandler[T]) HxMustCall added in v0.13.32

func (r *RouteHandler[T]) HxMustCall(payload Content, args ...Argument) *http.Response

MustCall is like Call and panics on errors

func (r *RouteHandler[T]) Link(argVals ...Argument) *Link

func (*RouteHandler[T]) Method

func (r *RouteHandler[T]) Method() string

func (*RouteHandler[T]) Mount

func (r *RouteHandler[T]) Mount(comp *Router[T])

func (*RouteHandler[T]) MountPath

func (r *RouteHandler[T]) MountPath() string

func (*RouteHandler[T]) MustCall

func (r *RouteHandler[T]) MustCall(payload Content, args ...Argument) *http.Response

MustCall is like Call and panics on errors

func (*RouteHandler[T]) Path

func (r *RouteHandler[T]) Path() string

func (*RouteHandler[T]) Scan

func (r *RouteHandler[T]) Scan(req *http.Request, targets ...Argument)

func (*RouteHandler[T]) ServeHTTP

func (r *RouteHandler[T]) ServeHTTP(wr http.ResponseWriter, req *http.Request)

func (*RouteHandler[T]) URL

func (r *RouteHandler[T]) URL(argVals ...Argument) string

panics when arg is missing

func (*RouteHandler[T]) WithArgs

func (r *RouteHandler[T]) WithArgs(_args ...Arg) *RouteHandler[T]

type Router

type Router[T Contexter] struct {
	Name   string
	Routes []*RouteHandler[T]
	// contains filtered or unexported fields
}

func New

func New[T Contexter](name string, mkContext func(Route, http.ResponseWriter, *http.Request) T) *Router[T]

func (*Router[T]) DELETE

func (c *Router[T]) DELETE(localpath string) *RouteHandler[T]

func (*Router[T]) GET

func (c *Router[T]) GET(localpath string) *RouteHandler[T]

func (*Router[T]) HEAD

func (c *Router[T]) HEAD(localpath string) *RouteHandler[T]

func (*Router[T]) Mount

func (c *Router[T]) Mount(rt *router.Router, pathPrefix string)

func (*Router[T]) OPTIONS

func (c *Router[T]) OPTIONS(localpath string) *RouteHandler[T]

func (*Router[T]) PATCH

func (c *Router[T]) PATCH(localpath string) *RouteHandler[T]

func (*Router[T]) POST

func (c *Router[T]) POST(localpath string) *RouteHandler[T]

func (*Router[T]) PUT

func (c *Router[T]) PUT(localpath string) *RouteHandler[T]

func (*Router[T]) Path

func (c *Router[T]) Path() string

func (*Router[T]) SetVerbose

func (c *Router[T]) SetVerbose() *Router[T]

func (*Router[T]) SubRouter

func (rt *Router[T]) SubRouter(name string, prefix string) *Router[T]

SubRouter returns a new router that is a copy of rt, but with a different name and empty/different routes and a prefix that is applied when mounting a subrouter can be mounted directly or via its parent (subrouter are tracked within their parents)

func (*Router[T]) Use

func (rt *Router[T]) Use(fn func(next func(T)) func(T)) *Router[T]

type Text

type Text struct {
	Data string
}

func NewText

func NewText(data string) *Text

func (Text) ContentType

func (s Text) ContentType() string

func (*Text) ReadFrom

func (t *Text) ReadFrom(rd io.Reader) error

func (Text) WriteTo

func (t Text) WriteTo(wr io.Writer) error

type XML

type XML struct {
	Data any
}

func NewXML

func NewXML(data any) *XML

func (XML) ContentType

func (s XML) ContentType() string

func (*XML) ReadFrom

func (s *XML) ReadFrom(rd io.Reader) error

func (*XML) WriteTo

func (s *XML) WriteTo(wr io.Writer) error

Directories

Path Synopsis
example
server command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL