handler

package
v0.0.0-...-f30d65c Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProxy

func NewProxy(remote string) http.Handler

Types

type ConfigRewrite

type ConfigRewrite = struct {
	Source      string `json:"source" validate:"min=1"`
	Destination string `json:"destination" validate:"min=1"`
}

type Configuration

type Configuration = struct {
	// Directory for static content
	Public string `json:"public"`

	NoCleanUrls bool
	CleanUrls   []string `json:"cleanUrls"`

	Rewrites []ConfigRewrite `json:"rewrites"`
	Proxy    []struct {
		Source      string `json:"source" validate:"min=1"`
		Destination string `json:"destination" validate:"min=1"`
	} `json:"proxy"`
	Redirects []struct {
		Source      string `json:"source" validate:"min=1"`
		Destination string `json:"destination" validate:"min=1"`
		Type        int    `json:"type"`
	} `json:"redirects"`

	Headers []struct {
		Source  string `json:"source" validate:"min=1,max=100"`
		Headers []struct {
			Key   string `json:"key" validate:"min=1,max=128,"`
			Value string `json:"value" validate:"min=1,max=2048,"`
		}
	} `json:"headers"`
	NoDirectoryListing bool
	DirectoryListing   []string `json:"directoryListing"`
	Unlisted           []string `json:"unlisted"`
	TrailingSlash      bool     `json:"trailingSlash"`
	RenderSingle       bool     `json:"renderSingle"`
	Symlinks           bool     `json:"symlinks"`
	Ssl                struct {
		KeyFile  string `json:"keyFile"`
		CertFile string `json:"certFile"`
	} `json:"ssl"`

	// Not in the config spec
	Debug         bool
	Listen        string
	Clipboard     bool
	NoCompression bool
}

func LoadServeConfiguration

func LoadServeConfiguration(filepath string) (Configuration, error)

type HandlerState

type HandlerState struct {
	Configuration
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(config Configuration) HandlerState

Implements http.Handler

func (HandlerState) AttachRoutes

func (state HandlerState) AttachRoutes(router chi.Router)

func (HandlerState) ServeHTTP

func (state HandlerState) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Logger

type Logger interface {
	Debug(string, ...interface{})
}

func NewLogger

func NewLogger(debug bool) Logger

NewLogger is a hack to enable/disable logging quickly without putting the logic throughout the code

type Set

type Set map[string]struct{}

Jump to

Keyboard shortcuts

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