httpserver

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: MIT Imports: 7 Imported by: 0

README

httpserver

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(opts ...opt) error

ListenAndServe is a shortcut for New(opts...).ListenAndServe()

func Run

func Run(ctx context.Context, opts ...opt) error

Run is a shortcut for New(opts...).Run(ctx)

func WithAddress

func WithAddress(host string, port uint16) opt

func WithHandler

func WithHandler(handler http.Handler) opt

func WithIdleTimeout

func WithIdleTimeout(d time.Duration) opt

func WithMaxHeaderBytes

func WithMaxHeaderBytes(i int) opt

func WithReadHeaderTimeout

func WithReadHeaderTimeout(d time.Duration) opt

func WithReadTimeout

func WithReadTimeout(d time.Duration) opt

func WithShutdownTimeout

func WithShutdownTimeout(d time.Duration) opt

func WithTLSConfig

func WithTLSConfig(conf *tls.Config) opt

func WithWriteTimeout

func WithWriteTimeout(d time.Duration) opt

Types

type Server

type Server interface {
	// ListenAndServe is a wrapper for http.Server.ListenAndServe method, that
	// returns nil when Server is closed. Otherwise, it always returns non-nil error
	ListenAndServe() error

	// Run runs http server and gracefully shuts it down on context cancellation. It
	// works well in conjunction with custom os signals handling via context (signal.NotifyContext)
	Run(ctx context.Context) error
}

Server is an interface for http server

func New

func New(opts ...opt) Server

New creates and returns new Server with given options. Default options: - read timeout 30s - write timeout 30s - shutdown timeout 5s

Directories

Path Synopsis
example
listen command
run command

Jump to

Keyboard shortcuts

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