server

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: MIT Imports: 7 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 {
	HTTP HTTP
}

Config represents the config object for the server.

type HTTP

type HTTP struct {
	Host string // optional, empty corresponds to "0.0.0.0"
	Port uint64
}

HTTP represents the http config object for the http server.

func (HTTP) Enabled

func (h HTTP) Enabled() bool

Enabled returns true if the http server is enabled (i.e. the Port is non-zero).

type Handler

type Handler struct {
	Path    string
	Handler http.Handler
}

Handler is a handler.

type Middleware

type Middleware func(http.Handler) http.Handler

type Server

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

Server is a server, that currently only supports HTTP.

func New

func New(cfg *Config, logger log.Logger, middlewares ...Middleware) *Server

New creates a new server.

func (*Server) RegisterHandler

func (s *Server) RegisterHandler(h *Handler)

RegisterHandler registers a handler.

func (*Server) RegisterMiddleware

func (s *Server) RegisterMiddleware(m Middleware)

RegisterMiddleware registers a middleware.

func (*Server) Start

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

Start starts the server. It is blocking so must run in a go-routine.

func (*Server) Stop

func (s *Server) Stop()

Stop stops the server.

Jump to

Keyboard shortcuts

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