httpserver

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: MIT Imports: 9 Imported by: 0

README

A Simple Golang Server with Graceful shutdown

Note This library doesn't handle routing

Usage

Check out example directory!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Server)

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger configures error and server logger

func WithServerTimeouts

func WithServerTimeouts(readTimeout, writeTimeout, idleTimeout time.Duration) Option

WithServerTimeouts configures "net/http".Server ReadTimeout, WriteTimeout and IdleTimeout

func WithShutdownTimeout

func WithShutdownTimeout(timeout time.Duration) Option

WithShutdownTimeout so server doesn't exceed the provided duration after receiving a stop signal

type Server

type Server struct {
	HTTPServer *http.Server
	// contains filtered or unexported fields
}

func New

func New(address string, port uint, handler http.Handler, options ...Option) *Server

func (*Server) AddShutdownHook added in v0.4.3

func (s *Server) AddShutdownHook(hook func(context.Context) error)

func (*Server) Context added in v0.5.0

func (s *Server) Context() context.Context

func (*Server) Run

func (s *Server) Run() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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