httputil

package
v1.0.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultShutdownTimeout = time.Second * 5
)

Variables

This section is empty.

Functions

func JSON added in v1.0.0

func JSON(w http.ResponseWriter, status int, data interface{}) error

func NewHandler

func NewHandler(handler Handler) http.HandlerFunc

func NoContent

func NoContent(w http.ResponseWriter) error

func RunServer

func RunServer(options ServerOptions) error

func String

func String(w http.ResponseWriter, status int, data string) error

Types

type Error added in v1.0.0

type Error struct {
	Type        string `json:"type,omitempty"`
	Description string `json:"description"`
	Field       string `json:"field,omitempty"`
}

func NewErrorsForJSONSchema

func NewErrorsForJSONSchema(errors []gojsonschema.ResultError) (result []Error)

func NewValidationErrors added in v1.0.0

func NewValidationErrors(field string, errors []string) (result []Error)

func (Error) Error added in v1.0.0

func (e Error) Error() string

type Handler

type Handler func(w http.ResponseWriter, r *http.Request) error

type Response added in v1.0.0

type Response struct {
	StatusCode int     `json:"-"`
	Errors     []Error `json:"errors,omitempty"`
}

func (Response) Error added in v1.0.0

func (r Response) Error() string

type ServerOptions

type ServerOptions struct {
	Name            string
	Address         string
	Handler         http.Handler
	ShutdownTimeout time.Duration
	Logger          logr.Logger
	Stop            <-chan struct{}
}

Jump to

Keyboard shortcuts

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