webserver

package module
v0.0.0-...-2293720 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: MIT Imports: 6 Imported by: 0

README

webserver

Bootstrap the creation of a HTTP(S) web server.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr string    `json:"address"`
	Port int       `json:"port"`
	TLS  TLSConfig `json:"tls"`
}

Config ...

type Server

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

Server is a wrapper around http.Server that provides a graceful shutdown and other helpful features.

func NewServer

func NewServer(cfg Config) *Server

NewServer creates a new server.

func (*Server) GetLogger

func (s *Server) GetLogger() *slog.Logger

GetLogger returns the logger for the server.

func (*Server) Router

func (s *Server) Router() *mux.Router

Router returns the router for the server.

func (*Server) Run

func (s *Server) Run() error

Run the web server (blocking).

func (*Server) SetLogger

func (s *Server) SetLogger(l *slog.Logger)

SetLogger sets the logger for the server.

func (*Server) Start

func (s *Server) Start()

Start the web server asynchronously (does not block).

func (*Server) Stop

func (s *Server) Stop() error

Stop gracefully stops the server.

type TLSConfig

type TLSConfig struct {
	Enabled  bool   `json:"enabled"`
	CertFile string `json:"certPath"`
	KeyFile  string `json:"keyPath"`
}

TLSConfig ...

Jump to

Keyboard shortcuts

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