gobaserver

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

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

Go to latest
Published: Sep 30, 2021 License: MIT Imports: 9 Imported by: 0

README

gobaserver

Documentation

Index

Constants

View Source
const BASIC = "Basic"

BASIC is the prefix of basic authorization headers.

Variables

View Source
var (
	// ErrEmptyAuthHeader occurs when an authorization header is empty.
	ErrEmptyAuthHeader = errors.New("authorization header is empty")

	// ErrAuthHeaderNotBasic occurs when an authorization header is not basic.
	ErrAuthHeaderNotBasic = errors.New("authorization header type must be \"basic\"")

	// ErrInvalidAuthHeader occurs when an authorization header is invalid.
	ErrInvalidAuthHeader = errors.New("invalid authorization header")
)
View Source
var ErrInvalidCredentials = errors.New("invalid credentials")

ErrInvalidCredentials occurs when credentials have been provided to an endpoint that are not known to the server.

Functions

This section is empty.

Types

type Credentials

type Credentials struct {
	// Username is the Credentials' username.
	Username string `json:"username,omitempty"`

	// Password is the Credentials' password.
	Password string `json:"password,omitempty"`
}

Credentials are credentials for interacting with the Server.

type ErrorResponse

type ErrorResponse struct {
	// Error describes the reason why the request failed.
	Error string `json:"error,omitempty"`
}

ErrorResponse represents a response to a failed request.

type Server

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

A Server provides a web interface for interacting with a goba.Goba.

func New

func New(goba goba.Goba, validCredentials ...Credentials) *Server

New creates a new configured Server and returns it.

func (Server) ListenAndServe

func (s Server) ListenAndServe(addr string) error

ListenAndServe serves HTTP requests from the given TCP address.

func (Server) ListenAndServeTLS

func (s Server) ListenAndServeTLS(addr, certFile, keyFile string) error

ListenAndServeTLS serves HTTP requests from the given TCP address. certFile and keyFile are paths to TLS certificate and key files.

Jump to

Keyboard shortcuts

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