http

package
v0.0.0-...-6343e97 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrAddRoutes is the error returned when adding routes to the router fails.
	ErrAddRoutes = errors.Error("failed to add routes")
	// ErrServer is the error returned when the server stops due to an error.
	ErrServer = errors.Error("listen stopped with error")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Port string `yaml:"port"`
}

Config represents the configuration of the http listener.

type Server

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

Server represents a http server that listens on a port.

func New

func New(s Service, cfg Config) (*Server, error)

New instantiates a new instance of Server.

func (*Server) Listen

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

Listen starts the server and listens on the configured port.

type Service

type Service interface {
	AddRoutes(r *mux.Router) error
}

Service represents a http service that provides routes for the listener.

Jump to

Keyboard shortcuts

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