Documentation ¶
Index ¶
- func LoveHandler(h http.Handler) http.HandlerFunc
- func WrapIPFilter(next http.Handler, opts IPFilterOptions) http.Handler
- type IPFilterOptions
- type OptionFn
- func CorsDomains(s string) OptionFn
- func EmailContact(emailContact string) OptionFn
- func EnableProfiler() OptionFn
- func FilterOptions(options IPFilterOptions) OptionFn
- func ForceHTTPS() OptionFn
- func HTTPAuthCredentials(user string, pass string) OptionFn
- func Listener(s string) OptionFn
- func LogFile(logger *log.Logger, s string) OptionFn
- func Logger(logger *log.Logger) OptionFn
- func MaxUploadSize(kbytes int64) OptionFn
- func ProfileListener(s string) OptionFn
- func ProxyPath(s string) OptionFn
- func ProxyPort(s string) OptionFn
- func Purge(days, interval int) OptionFn
- func RandomTokenLength(length uint64) OptionFn
- func RateLimit(requests int) OptionFn
- func SecretTokenLength(length int) OptionFn
- func TLSConfig(cert, pk string) OptionFn
- func TLSListener(s string, t bool) OptionFn
- func TempPath(s string) OptionFn
- func UseLetsEncrypt(hosts []string) OptionFn
- func UseStorage(s storage.Storage) OptionFn
- func WebPath(s string) OptionFn
- type Server
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
CorsDomains sets CORS domains
func EmailContact ¶ added in v1.5.0
EmailContact sets email contact
func FilterOptions ¶ added in v1.5.0
func FilterOptions(options IPFilterOptions) OptionFn
FilterOptions sets ip filtering
func HTTPAuthCredentials ¶ added in v1.5.0
HTTPAuthCredentials sets basic http auth credentials
func MaxUploadSize ¶ added in v1.5.0
MaxUploadSize sets max upload size
func ProfileListener ¶
ProfileListener sets profile listener
func RandomTokenLength ¶ added in v1.5.0
RandomTokenLength sets random token length
func SecretTokenLength ¶ added in v1.5.6
SecretTokenLength sets random token length
func TLSListener ¶
TLSListener sets TLS listener and option
func UseLetsEncrypt ¶
UseLetsEncrypt set letsencrypt usage
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 (*Server) RedirectHandler ¶
func (s *Server) RedirectHandler(h http.Handler) http.HandlerFunc
RedirectHandler handles redirect