Documentation
¶
Index ¶
- type BinaryRequestReader
- type BinaryResponseWriter
- type BodyMethod
- type BodyResponseMethod
- type ContentType
- type Func
- type Handler
- type JsonRequestReader
- type JsonResponseWriter
- type Method
- type Request
- type RequestReader
- type RequestReaderFunc
- type ResponseMethod
- type ResponseMethodContentTypeOverride
- type ResponseWriter
- type StaticResponse
- type TextRequestReader
- type TextResponseWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinaryRequestReader ¶
type BinaryRequestReader struct{}
type BinaryResponseWriter ¶
type BinaryResponseWriter struct{}
func (BinaryResponseWriter) ContentType ¶
func (jrw BinaryResponseWriter) ContentType(r *http.Request) ContentType
func (BinaryResponseWriter) Serialize ¶
func (jrw BinaryResponseWriter) Serialize(w http.ResponseWriter, response []byte) (err error)
type BodyMethod ¶
type BodyMethod[Body any] struct { Request RequestReader[Body] Handler func(request Request[Body]) error }
func JsonBodyMethod ¶ added in v0.31.0
func JsonBodyMethod[Body any](handler func(request Request[Body]) error) BodyMethod[Body]
func (BodyMethod[Body]) ContentType ¶
func (jse BodyMethod[Body]) ContentType(r *http.Request) ContentType
func (BodyMethod[Body]) Handle ¶
func (jse BodyMethod[Body]) Handle(w http.ResponseWriter, r *http.Request)
type BodyResponseMethod ¶
type BodyResponseMethod[Body any, Response any] struct { Request RequestReader[Body] ResponseWriter ResponseWriter[Response] Handler func(request Request[Body]) (Response, error) }
func JsonMethod ¶
func JsonMethod[Body any, Response any](handler func(request Request[Body]) (Response, error)) BodyResponseMethod[Body, Response]
func (BodyResponseMethod[Body, Response]) ContentType ¶
func (jse BodyResponseMethod[Body, Response]) ContentType(r *http.Request) ContentType
func (BodyResponseMethod[Body, Response]) Handle ¶
func (jse BodyResponseMethod[Body, Response]) Handle(w http.ResponseWriter, r *http.Request)
type ContentType ¶
type ContentType string
const ( BinaryContentType ContentType = "application/octet-stream" JsonContentType ContentType = "application/json" PlainTextContentType ContentType = "text/plain" )
type Func ¶ added in v0.21.0
func (Func) ContentType ¶ added in v0.21.0
func (jse Func) ContentType(r *http.Request) ContentType
type JsonRequestReader ¶
type JsonRequestReader[T any] struct{}
type JsonResponseWriter ¶
type JsonResponseWriter[Response any] struct{}
func (JsonResponseWriter[Response]) ContentType ¶
func (jrw JsonResponseWriter[Response]) ContentType(r *http.Request) ContentType
func (JsonResponseWriter[Response]) Serialize ¶
func (jrw JsonResponseWriter[Response]) Serialize(w http.ResponseWriter, response Response) (err error)
type Method ¶
type Method interface {
ContentType(r *http.Request) ContentType
Handle(w http.ResponseWriter, r *http.Request)
}
type RequestReaderFunc ¶ added in v0.32.0
type ResponseMethod ¶
type ResponseMethod[Response any] struct { ResponseWriter ResponseWriter[Response] Handler func(r *http.Request) (Response, error) }
func JsonResponseMethod ¶ added in v0.31.0
func JsonResponseMethod[Response any](handler func(r *http.Request) (Response, error)) ResponseMethod[Response]
func (ResponseMethod[Response]) ContentType ¶
func (jse ResponseMethod[Response]) ContentType(r *http.Request) ContentType
func (ResponseMethod[Response]) Handle ¶
func (jse ResponseMethod[Response]) Handle(w http.ResponseWriter, r *http.Request)
type ResponseMethodContentTypeOverride ¶ added in v0.33.0
type ResponseMethodContentTypeOverride[Response any] struct { ResponseWriter ResponseWriter[Response] Content func(r *http.Request) ContentType Handler func(r *http.Request) (Response, error) }
func (ResponseMethodContentTypeOverride[Response]) ContentType ¶ added in v0.33.0
func (jse ResponseMethodContentTypeOverride[Response]) ContentType(r *http.Request) ContentType
func (ResponseMethodContentTypeOverride[Response]) Handle ¶ added in v0.33.0
func (jse ResponseMethodContentTypeOverride[Response]) Handle(w http.ResponseWriter, r *http.Request)
type ResponseWriter ¶
type ResponseWriter[Response any] interface { Serialize(w http.ResponseWriter, response Response) (err error) ContentType(r *http.Request) ContentType }
type StaticResponse ¶ added in v0.32.0
func StaticJson ¶ added in v0.32.0
func StaticJson(data any) (StaticResponse, error)
func (StaticResponse) ContentType ¶ added in v0.32.0
func (srw StaticResponse) ContentType(r *http.Request) ContentType
func (StaticResponse) Handle ¶ added in v0.32.0
func (srw StaticResponse) Handle(w http.ResponseWriter, r *http.Request)
type TextRequestReader ¶ added in v0.21.0
type TextRequestReader struct{}
type TextResponseWriter ¶ added in v0.21.0
type TextResponseWriter struct{}
func (TextResponseWriter) ContentType ¶ added in v0.21.0
func (jrw TextResponseWriter) ContentType(r *http.Request) ContentType
func (TextResponseWriter) Serialize ¶ added in v0.21.0
func (jrw TextResponseWriter) Serialize(w http.ResponseWriter, response string) (err error)
Click to show internal directories.
Click to hide internal directories.