Documentation ¶
Index ¶
- Constants
- func BuildInfoAsHtmlFunc(bi BuildInfoer) func() template.HTML
- func CanonicalizeHandler(logger *slog.Logger, domainCanonicalizer RedirectFunc, ...) http.Handler
- func DontRedirect(*http.Request) (url.URL, int)
- func EnvOr(key, defaultVal string) string
- func FlyInfoAsHtmlFunc(fi FlyInfoer) func() template.HTML
- func GenBase32Etag(b []byte) string
- func GetGitInfo() string
- func GetNonceOrDefault(ctx context.Context, defaultVal string) string
- func GetRequestIdOrDefault(ctx context.Context, defaultVal string) string
- func HeaderOr(hdr http.Header, key, defaultVal string) []string
- func RecoverPanicHandler(logger *slog.Logger, next http.Handler) http.Handler
- func RewriteHandler(logger *slog.Logger, rewrite map[string]string, next http.Handler) http.Handler
- func SecurityHeadersHandler(logger *slog.Logger, next http.Handler) http.Handler
- func TagRequestWithUniqueIdHandler(logger *slog.Logger, next http.Handler) http.Handler
- type BuildInfoer
- type FlyInfoer
- type RedirTarget
- type RedirectFunc
- type ServerWithShutdown
- type Setting
- type SettingKind
- type Static
Constants ¶
View Source
const ( LOCAL_DEV_REGION = "region_local_dev" LOCAL_DEV_ALLOC_ID = "dev1234" )
View Source
const ( DefaultIdleTimeout = 30 * time.Second DefaultReadTimeout = 5 * time.Second DefaultWriteTimeout = 10 * time.Second DefaultShutdownTimeout = 30 * time.Second )
View Source
const (
HSTS_max_age_seconds = 60 * 60 * 24 * 90 // 90 days
)
Variables ¶
This section is empty.
Functions ¶
func BuildInfoAsHtmlFunc ¶
func BuildInfoAsHtmlFunc(bi BuildInfoer) func() template.HTML
Forced into this API to make it easily invocable by template
func CanonicalizeHandler ¶
func CanonicalizeHandler( logger *slog.Logger, domainCanonicalizer RedirectFunc, pathCanonicalizer RedirectFunc, next http.Handler, ) http.Handler
func FlyInfoAsHtmlFunc ¶
Forced into this API to make it easily invocable by template
func GenBase32Etag ¶
Base64 uses '/' and '+' chars and I'm not sure '+' is valid for ETAGs, so we use Base32 to cut risk
func GetGitInfo ¶
func GetGitInfo() string
func GetRequestIdOrDefault ¶
func RecoverPanicHandler ¶
func RewriteHandler ¶
func RewriteHandler( logger *slog.Logger, rewrite map[string]string, next http.Handler, ) http.Handler
Transparent internal rewrites
func SecurityHeadersHandler ¶
XXX As written, attacker may be able to potentially exhaust random pool!
Types ¶
type BuildInfoer ¶
type BuildInfoer interface {
GitRevision() string
}
type RedirTarget ¶
type RedirectFunc ¶
Returns "to" URL and redirection code if redirection warranted Returns code==0 if no redirection indicated
func DomainCanonicalizer ¶
func DomainCanonicalizer( logger *slog.Logger, canonFQDN string, secondaryFQDNs []string, ) RedirectFunc
Should probably only be invoked in local/dev mode and not production Returned func returns (nil, http.StatusBadGateway) on error
func PathCanonicalizer ¶
func PathCanonicalizer( logger *slog.Logger, redirMap map[string]RedirTarget, ) RedirectFunc
Redirect old URLs picked up by search engines
type ServerWithShutdown ¶
type ServerWithShutdown struct {
// contains filtered or unexported fields
}
func NewServerWithShutdown ¶
func NewServerWithShutdown() *ServerWithShutdown
func (*ServerWithShutdown) Shutdown ¶
func (s *ServerWithShutdown) Shutdown() error
This should panic if called twice
type Setting ¶
type Setting struct { Kind SettingKind Val int }
type SettingKind ¶
type SettingKind int
const ( CfgIdleTimeout SettingKind = iota CfgReadTimeout CfgWriteTimeout CfgShutdownTimeout )
Click to show internal directories.
Click to hide internal directories.