servemux

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handle

func Handle[T any](config *HandlerConfig, handlers ...HandlerFunc[T]) http.HandlerFunc

func WithHandlerConfigSerializer

func WithHandlerConfigSerializer(serializer serialization.ISerializer) func(*HandlerConfig)

func WithHandlerMaxMemSize

func WithHandlerMaxMemSize(size int64) func(*HandlerConfig)

Types

type HandlerConfig

type HandlerConfig struct {
	// contains filtered or unexported fields
}

func NewHandlerConfig

func NewHandlerConfig(opts ...func(*HandlerConfig)) *HandlerConfig

type HandlerFunc

type HandlerFunc[T any] func(ctx *HttpCtx[T])

type HttpCtx

type HttpCtx[T any] struct {
	// contains filtered or unexported fields
}

func NewHttpCtx

func NewHttpCtx[T any](req *http.Request, responseWriter http.ResponseWriter, serializer serialization.ISerializer, maxMemSize int64) *HttpCtx[T]

func (*HttpCtx[T]) Abort added in v0.3.2

func (h *HttpCtx[T]) Abort()

func (*HttpCtx[T]) AbortWithResponse added in v0.3.3

func (h *HttpCtx[T]) AbortWithResponse(statusCode int, body any)

func (*HttpCtx[T]) AddHeader added in v0.3.1

func (h *HttpCtx[T]) AddHeader(name string, value string)

func (*HttpCtx[T]) Context

func (h *HttpCtx[T]) Context() context.Context

func (*HttpCtx[T]) DelHeader added in v0.3.1

func (h *HttpCtx[T]) DelHeader(name string)

func (*HttpCtx[T]) Error

func (h *HttpCtx[T]) Error(err error)

func (*HttpCtx[T]) Errors

func (h *HttpCtx[T]) Errors() []error

func (*HttpCtx[T]) GetBody

func (h *HttpCtx[T]) GetBody() (T, error)

func (*HttpCtx[T]) GetFiles

func (h *HttpCtx[T]) GetFiles() map[string][]*multipart.FileHeader

func (*HttpCtx[T]) GetHeader

func (h *HttpCtx[T]) GetHeader(name string) []string

func (*HttpCtx[T]) GetQueryParam

func (h *HttpCtx[T]) GetQueryParam(name string) string

func (*HttpCtx[T]) GetRawRequest added in v0.3.6

func (h *HttpCtx[T]) GetRawRequest() *http.Request

func (*HttpCtx[T]) GetRawResponseWriter added in v0.3.6

func (h *HttpCtx[T]) GetRawResponseWriter() http.ResponseWriter

func (*HttpCtx[T]) GetResponseBody

func (h *HttpCtx[T]) GetResponseBody() any

func (*HttpCtx[T]) GetStatusCode

func (h *HttpCtx[T]) GetStatusCode() int

func (*HttpCtx[T]) GetUrlParam

func (h *HttpCtx[T]) GetUrlParam(name string) string

func (*HttpCtx[T]) SetHeader added in v0.3.1

func (h *HttpCtx[T]) SetHeader(name string, value string)

func (*HttpCtx[T]) SetResponseBody

func (h *HttpCtx[T]) SetResponseBody(value any)

func (*HttpCtx[T]) SetStatusCode

func (h *HttpCtx[T]) SetStatusCode(code int)

func (*HttpCtx[T]) Stream

func (h *HttpCtx[T]) Stream(step func() (ServerSentEvent, bool)) (bool, error)

type ServerSentEvent

type ServerSentEvent struct {
	Event string // Event type (e.g. "message")
	Data  any    // Data (will be serialized using given serializer)
}

Jump to

Keyboard shortcuts

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