http

package
v0.0.0-...-a46f264 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package http handles everything related to HTTP.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(w http.ResponseWriter, err error, code int)

Error writes an error message to the response.

func ListenAndServe

func ListenAndServe(addr string, handler http.Handler) error

ListenAndServe is a wrapper for http.ListenAndServe.

func ServeAutoCert

func ServeAutoCert(addr string, handler http.Handler, cache string, domains ...string) error

ServeAutoCert will serve on the standard TLS port (443) with LetsEncrypt certificates for the provided domain or domains. Certificates will be stored in the given cache directory. Incoming traffic on port 80 will be automatically forwared to 443.

Types

type Handler

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

Handler serves various HTTP endpoints.

func NewHandler

func NewHandler(options ...Option) *Handler

NewHandler creates a new HTTP handler with the given options and initializes all routes.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Option

type Option func(h *Handler)

Option controls some aspects of the Handler.

func WithDatabase

func WithDatabase(db browser.Database) Option

WithDatabase returns an options function for setting the handler's database backend.

func WithDevMode

func WithDevMode(mode bool) Option

func WithPlausible

func WithPlausible(use bool) Option

func WithStationService

func WithStationService(s browser.StationService) Option

WithStationService returns an option function for setting the handlers's stationService.

Jump to

Keyboard shortcuts

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