dynhttpsrv

package module
v0.0.0-...-9477ea8 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

Dynamic HTTP Server (dynhttpsrv)

A Go HTTP server which you can programatically:

  • Start and stop multiple servers on various addresses
  • Cancel it through the provided context
  • Add/Remove endpoints while serving with no glitch

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DynHttpSrv

type DynHttpSrv struct {
	Router    *swappableRouter
	Endpoints []*Endpoint
}

func New

func New(ctx context.Context, addr string) *DynHttpSrv

New creates a new dynamic HTTP server listening on address and obeying cancelling through ctx

func (*DynHttpSrv) AddEndpoint

func (dhs *DynHttpSrv) AddEndpoint(endpoint *Endpoint) error

func (*DynHttpSrv) DelEndpoint

func (dhs *DynHttpSrv) DelEndpoint(endpoint *Endpoint) error

type Endpoint

type Endpoint struct {
	Methods []string
	Paths   []string
	Handler func(res http.ResponseWriter, req *http.Request)
}

Jump to

Keyboard shortcuts

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