server

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(r io.Reader, out any, processors ...func(any) error) error

Decode decodes a reader, unmarshalls the bytes into the out interface as json

func DecodeValidate

func DecodeValidate(r io.Reader, v *validator.Validate, out interface{}) error

DecodeValidate decodes a reader, unmarshalls the bytes into the out interface as json, and validates it

func Encode

func Encode(w http.ResponseWriter, status int, v any) error

func Validate

func Validate(v *validator.Validate) func(any) error

Validate is a processor function that will validate an interface with a given validator

Types

type Config

type Config struct {
	Port    int           `envconfig:"PORT" default:"8080"`
	Timeout time.Duration `envconfig:"TIMEOUT" default:"30s"`
}

type Router

type Router interface {
	Routes() *http.ServeMux
}

type Server

type Server struct {
	*http.Server
}

func New

func New(cfg Config, router Router) *Server

Jump to

Keyboard shortcuts

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