rutar

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// HeaderNameAuthorization is the name of the HTTP Authorization header
	HeaderNameAuthorization = "Authorization"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server interface {
	// AddRoute stores a route after validation
	AddRoute(method string, path string, hasAuth bool, handler http.Handler) error

	// AddOptionsRoutes adds OPTIONS handler for each route that has been added.
	// If age is 0, the default of 300 is used.
	// If origin is not specified, the default of "*" is used.
	AddOptionsRoutes(age int, origin string, logFunc func(http.Handler) http.Handler)

	// Config configures the internal `http.Server` that is used
	// This must be called before `Server.Start`
	//
	// This sets the following defaults:
	//
	//	ReadTimeout:       10 seconds,
	//	ReadHeaderTimeout: 2 seconds,
	//	WriteTimeout:      10 seconds,
	//
	// This can be changed using `Server.Server`
	Config(addr string, port int) error

	// Server returns the internal `http.Server`
	// This can be used to change options on the `http.Server`.
	//
	// This should be called after `Server.Config` otherwise it will return nil.
	Server() *http.Server

	// Start starts the `http.Server` listening process.
	//
	// logger can be nil if logging of startup is not desired.
	Start(logger func(string)) error
}

Server holds the http.Server, http.ServeMux and paths that are being served.

func NewServer

func NewServer() Server

NewServer returns a `rutar.Server` implementation

Jump to

Keyboard shortcuts

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