server

package
v0.0.0-...-dd674db Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	Token string `yaml:"token"`
}

AuthConfig is the configuration for authenticators

type Authenticator

type Authenticator interface {
	Authenticate(context.Context, map[string][]string) (context.Context, error)
}

Authenticator allows specifying the authentication strategy

func FindAuthenticator

func FindAuthenticator(n string, c AuthConfig) (Authenticator, error)

FindAuthenticator find the appropriate authenticator based on the specified name

type BearerTokenAuth

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

BearerTokenAuth performs authentication with a bearer token

func (BearerTokenAuth) Authenticate

func (b BearerTokenAuth) Authenticate(ctx context.Context, h map[string][]string) (context.Context, error)

Authenticate checks the request against bearer token authentication

type Config

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

Config holds all the config available for a server

type ConfigOption

type ConfigOption func(*Config)

ConfigOption allows passing a functional option when creating a new server

func WithAddr

func WithAddr(a string) ConfigOption

WithAddr specifies the address the server will listen on

func WithAuthenticator

func WithAuthenticator(a Authenticator) ConfigOption

WithAuthenticator allows specifying the authenticator

type Server

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

Server is an `http.Server` which knows how to serve our requests

func NewServer

func NewServer(dic *dictionary.Dictionary, opts ...ConfigOption) *Server

NewServer creates a new instance of server

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe starts the HTTP server and blocks until it finished running

func (*Server) Shutdown

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

Shutdown stops the server

func (*Server) URL

func (s *Server) URL() *url.URL

URL returns the URL attribute, locking as required

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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