httpserver

package
v4.22.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicAuthFieldSpec

func BasicAuthFieldSpec() docs.FieldSpec

BasicAuthFieldSpec returns the spec for an HTTP BasicAuth component.

func ServerCORSFieldSpec

func ServerCORSFieldSpec() docs.FieldSpec

ServerCORSFieldSpec returns a field spec for an http server CORS component.

Types

type BasicAuthConfig

type BasicAuthConfig struct {
	Enabled      bool   `json:"enabled" yaml:"enabled"`
	Username     string `json:"username" yaml:"username"`
	PasswordHash string `json:"password_hash" yaml:"password_hash"`
	Realm        string `json:"realm" yaml:"realm"`
	Algorithm    string `json:"algorithm" yaml:"algorithm"`
	Salt         string `json:"salt" yaml:"salt"`
}

BasicAuthConfig contains struct based fields for basic authentication.

func NewBasicAuthConfig

func NewBasicAuthConfig() BasicAuthConfig

NewBasicAuthConfig returns a BasicAuthConfig with default values.

func (BasicAuthConfig) Validate

func (b BasicAuthConfig) Validate() error

Validate confirms that the BasicAuth is properly configured.

func (BasicAuthConfig) WrapHandler

func (b BasicAuthConfig) WrapHandler(next http.HandlerFunc) http.HandlerFunc

WrapHandler wraps the provided HTTP handler with middleware that enforces BasicAuth if it's enabled.

type CORSConfig

type CORSConfig struct {
	Enabled        bool     `json:"enabled" yaml:"enabled"`
	AllowedOrigins []string `json:"allowed_origins" yaml:"allowed_origins"`
}

CORSConfig contains struct configuration for allowing CORS headers.

func NewServerCORSConfig

func NewServerCORSConfig() CORSConfig

NewServerCORSConfig returns a new server CORS config with default fields.

func (CORSConfig) WrapHandler

func (conf CORSConfig) WrapHandler(handler http.Handler) (http.Handler, error)

WrapHandler wraps a provided HTTP handler with middleware that enables CORS requests (when configured).

Jump to

Keyboard shortcuts

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