server

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: MIT Imports: 50 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoveHandler

func LoveHandler(h http.Handler) http.HandlerFunc

LoveHandler Create a log handler for every request it receives.

func WrapIPFilter added in v1.5.0

func WrapIPFilter(next http.Handler, opts IPFilterOptions) http.Handler

WrapIPFilter is equivalent to newIPFilter(opts) then Wrap(next)

Types

type IPFilterOptions added in v1.5.0

type IPFilterOptions struct {
	// explicitly allowed IPs
	AllowedIPs []string
	// explicitly blocked IPs
	BlockedIPs []string
	// block by default (defaults to allow)
	BlockByDefault bool
	// TrustProxy enable check request IP from proxy
	TrustProxy bool

	Logger interface {
		Printf(format string, v ...interface{})
	}
}

IPFilterOptions for ipFilter. Allowed takes precedence over Blocked. IPs can be IPv4 or IPv6 and can optionally contain subnet masks (/24). Note however, determining if a given IP is included in a subnet requires a linear scan so is less performant than looking up single IPs.

This could be improved with some algorithmic magic.

type OptionFn

type OptionFn func(*Server)

OptionFn is the option function type

func CorsDomains added in v1.5.0

func CorsDomains(s string) OptionFn

CorsDomains sets CORS domains

func EmailContact added in v1.5.0

func EmailContact(emailContact string) OptionFn

EmailContact sets email contact

func EnableProfiler

func EnableProfiler() OptionFn

EnableProfiler sets enable profiler

func FilterOptions added in v1.5.0

func FilterOptions(options IPFilterOptions) OptionFn

FilterOptions sets ip filtering

func ForceHTTPS added in v1.5.0

func ForceHTTPS() OptionFn

ForceHTTPS sets forcing https

func HTTPAuthCredentials added in v1.5.0

func HTTPAuthCredentials(user string, pass string) OptionFn

HTTPAuthCredentials sets basic http auth credentials

func Listener

func Listener(s string) OptionFn

Listener set listener

func LogFile

func LogFile(logger *log.Logger, s string) OptionFn

LogFile sets log file

func Logger

func Logger(logger *log.Logger) OptionFn

Logger sets logger

func MaxUploadSize added in v1.5.0

func MaxUploadSize(kbytes int64) OptionFn

MaxUploadSize sets max upload size

func ProfileListener

func ProfileListener(s string) OptionFn

ProfileListener sets profile listener

func ProxyPath added in v1.5.0

func ProxyPath(s string) OptionFn

ProxyPath sets proxy path

func ProxyPort added in v1.5.0

func ProxyPort(s string) OptionFn

ProxyPort sets proxy port

func Purge added in v1.5.0

func Purge(days, interval int) OptionFn

Purge sets purge days and option

func RandomTokenLength added in v1.5.0

func RandomTokenLength(length uint64) OptionFn

RandomTokenLength sets random token length

func RateLimit

func RateLimit(requests int) OptionFn

RateLimit set rate limit

func SecretTokenLength added in v1.5.6

func SecretTokenLength(length int) OptionFn

SecretTokenLength sets random token length

func TLSConfig

func TLSConfig(cert, pk string) OptionFn

TLSConfig sets TLS config

func TLSListener

func TLSListener(s string, t bool) OptionFn

TLSListener sets TLS listener and option

func TempPath

func TempPath(s string) OptionFn

TempPath sets temp path

func UseLetsEncrypt

func UseLetsEncrypt(hosts []string) OptionFn

UseLetsEncrypt set letsencrypt usage

func UseStorage

func UseStorage(s storage.Storage) OptionFn

UseStorage set storage to use

func WebPath

func WebPath(s string) OptionFn

WebPath sets web path

type Server

type Server struct {
	AuthUser string
	AuthPass string

	TLSListenerOnly bool

	CorsDomains           string
	ListenerString        string
	TLSListenerString     string
	ProfileListenerString string

	Certificate string

	LetsEncryptCache string
	// contains filtered or unexported fields
}

Server is the main application

func New

func New(options ...OptionFn) (*Server, error)

New is the factory fot Server

func (*Server) RedirectHandler

func (s *Server) RedirectHandler(h http.Handler) http.HandlerFunc

RedirectHandler handles redirect

func (*Server) Run

func (s *Server) Run()

Run starts Server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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