httpx

package
v0.0.0-...-9831a62 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(w http.ResponseWriter, logger errorLogger, err error, code int)

Error writes error response.

func InternalError

func InternalError(w http.ResponseWriter, logger errorLogger)

InternalError responsds with unknown internal error.

func JSON

func JSON(w http.ResponseWriter, logger errorLogger, response interface{}, code int)

JSON marshals objet as json and writes it to the response body.

Types

type Config

type Config struct {
	Addr string     `yaml:"addr"`
	TLS  *tlsConfig `yaml:"tls"`
}

Config contains http server configuration values.

type Server

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

Server represents an HTTP server.

func NewServer

func NewServer(cfg *Config, logger logger, handler http.Handler) (*Server, error)

NewServer creates a new HTTP server.

The handler can be nil, in which case http.DefaultServeMux is used.

func (*Server) Shutdown

func (srv *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shutdowns the server.

func (*Server) Start

func (srv *Server) Start() error

Start starts the server, handling incoming requests.

Accepted connections are configured to enable TCP keep-alives.

Jump to

Keyboard shortcuts

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