server

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2023 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrWriter

func ErrWriter(err error) func(writer io.Writer)

func File

func File(mime string, f io.Reader) func(req *http.Request) (int, string, func(io.Writer))

func Handle

func Handle(handlers ...any) func(w http.ResponseWriter, req *http.Request)

func Html

func Html(str string) func(req *http.Request) (int, string, func(io.Writer))

func JsonWriter

func JsonWriter(data any) func(writer io.Writer)

func ReaderWriter

func ReaderWriter(data io.Reader) func(writer io.Writer)

func Redirect added in v0.5.3

func Redirect(url string) (int, string, func(io.Writer))

func StringWriter

func StringWriter(str string) func(writer io.Writer)

Types

type ChainHandler

type ChainHandler func(w http.ResponseWriter, req *http.Request) bool
var Get ChainHandler = Method("GET")
var Path ChainHandler = Method("PATCH")
var Post ChainHandler = Method("POST")
var Put ChainHandler = Method("PUT")

func BasicAuthHandler

func BasicAuthHandler(user, pass string) ChainHandler

func Method

func Method(method string) ChainHandler

func NopHandler added in v0.5.1

func NopHandler() ChainHandler

type ResponseBuilder

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

func ErrBadRequest

func ErrBadRequest(body any) *ResponseBuilder

func ErrInternal

func ErrInternal(body any) *ResponseBuilder

func ErrNotFound

func ErrNotFound(body any) *ResponseBuilder

func NewResponse

func NewResponse() *ResponseBuilder

func Ok

func Ok(body any) *ResponseBuilder

func (*ResponseBuilder) As

func (rb *ResponseBuilder) As(contentType string) (int, string, func(io.Writer))

func (*ResponseBuilder) AsHtml

func (rb *ResponseBuilder) AsHtml() (int, string, func(io.Writer))

func (*ResponseBuilder) AsJson

func (rb *ResponseBuilder) AsJson() (int, string, func(io.Writer))

func (*ResponseBuilder) AsTextPlain

func (rb *ResponseBuilder) AsTextPlain() (int, string, func(io.Writer))

func (*ResponseBuilder) Body

func (rb *ResponseBuilder) Body(body any) *ResponseBuilder

func (*ResponseBuilder) Status

func (rb *ResponseBuilder) Status(status int) *ResponseBuilder

Jump to

Keyboard shortcuts

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