servio

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindJSON

func BindJSON(r *http.Request, v any) error

BindJSON decodes the request body as JSON value into 'v'.

func JSON

func JSON(w http.ResponseWriter, r *http.Request, status int, v any)

JSON encodes 'v' as JSON into the writer.

func JSONErr

func JSONErr(w http.ResponseWriter, r *http.Request, err error)

JSONErr writes the given error as JSON output. Status code is inferred from the error value.

func Serve

func Serve(ctx context.Context, addr string, handler http.Handler) error

Serve serves the given handler at addr.

Types

type ResponseWriterCapture

type ResponseWriterCapture struct {
	http.ResponseWriter

	Status int
}

func (*ResponseWriterCapture) WriteHeader

func (rwc *ResponseWriterCapture) WriteHeader(status int)

Jump to

Keyboard shortcuts

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