httpserver

package
v0.0.0-...-4ec33cd Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Address string `kong:"default=127.0.0.1:8080"`
}

func (Config) Build

func (c Config) Build(ctx context.Context) (*Server, error)

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithConfig

func WithConfig(c Config) Option

func WithServerAddress

func WithServerAddress(network string, address string) Option

type Server

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

func New

func New(options ...Option) (*Server, error)

New creates a new HTTP server

func (*Server) AddMiddleware

func (s *Server) AddMiddleware(middleware func(http.Handler) http.Handler)

TODO: allow setting a matcher on middleware?

func (*Server) Handle

func (s *Server) Handle(pattern string, handler http.Handler)

Handle adds a handler for the given pattern.

func (*Server) RegisterService

func (s *Server) RegisterService(t TwirpServer)

RegisterService registers twirp service

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

func (*Server) WaitForAddress

func (s *Server) WaitForAddress(ctx context.Context) (net.Addr, error)

WaitForAddress waits until an address is assigned. Useful when generating a listening socket.

type TwirpServer

type TwirpServer interface {
	reflection.TwirpServer
	http.Handler
}

Jump to

Keyboard shortcuts

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