github.com/blend/go-sdk@v1.20220411.3/web/constants.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package web
     9  
    10  import (
    11  	"net/http"
    12  	"time"
    13  )
    14  
    15  const (
    16  	// PackageName is the full name of this package.
    17  	PackageName = "github.com/blend/go-sdk/web"
    18  	// RouteTokenFilepath is a special route token.
    19  	RouteTokenFilepath = "filepath"
    20  	// RegexpAssetCacheFiles is a common regex for parsing css, js, and html file routes.
    21  	RegexpAssetCacheFiles = `^(.*)\.([0-9]+)\.(css|js|html|htm)$`
    22  	// FieldTagPostForm is a field tag you can use to set a struct from a post body.
    23  	FieldTagPostForm = "postForm"
    24  )
    25  
    26  const (
    27  	// DefaultBindAddr is the default bind address.
    28  	DefaultBindAddr = ":8080"
    29  	// DefaultHealthzBindAddr is the default healthz bind address.
    30  	DefaultHealthzBindAddr = ":8081"
    31  	// DefaultMockBindAddr is a bind address used for integration testing.
    32  	DefaultMockBindAddr = "127.0.0.1:0"
    33  	// DefaultSkipRedirectTrailingSlash is the default if we should redirect for missing trailing slashes.
    34  	DefaultSkipRedirectTrailingSlash = false
    35  	// DefaultHandleOptions is a default.
    36  	DefaultHandleOptions = false
    37  	// DefaultHandleMethodNotAllowed is a default.
    38  	DefaultHandleMethodNotAllowed = false
    39  	// DefaultRecoverPanics returns if we should recover panics by default.
    40  	DefaultRecoverPanics = true
    41  	// DefaultMaxHeaderBytes is a default that is unset.
    42  	DefaultMaxHeaderBytes = 0
    43  	// DefaultReadTimeout is a default.
    44  	DefaultReadTimeout = 0
    45  	// DefaultReadHeaderTimeout is a default.
    46  	DefaultReadHeaderTimeout time.Duration = 0
    47  	// DefaultWriteTimeout is a default.
    48  	DefaultWriteTimeout time.Duration = 0
    49  	// DefaultIdleTimeout is a default.
    50  	DefaultIdleTimeout time.Duration = 0
    51  	// DefaultCookieName is the default name of the field that contains the session id.
    52  	DefaultCookieName = "SID"
    53  	// DefaultSecureCookieName is the default name of the field that contains the secure session id.
    54  	DefaultSecureCookieName = "SSID"
    55  	// DefaultCookiePath is the default cookie path.
    56  	DefaultCookiePath = "/"
    57  	// DefaultCookieSecure returns what the default value for the `Secure` bit of issued cookies will be.
    58  	DefaultCookieSecure = true
    59  	// DefaultCookieHTTPOnly returns what the default value for the `HTTPOnly` bit of issued cookies will be.
    60  	DefaultCookieHTTPOnly = true
    61  	// DefaultCookieSameSiteMode is the default cookie same site mode (currently http.SameSiteLaxMode).
    62  	DefaultCookieSameSiteMode = http.SameSiteLaxMode
    63  	// DefaultSessionTimeout is the default absolute timeout for a session (24 hours as a sane default).
    64  	DefaultSessionTimeout time.Duration = 24 * time.Hour
    65  	// DefaultUseSessionCache is the default if we should use the auth manager session cache.
    66  	DefaultUseSessionCache = true
    67  	// DefaultSessionTimeoutIsAbsolute is the default if we should set absolute session expiries.
    68  	DefaultSessionTimeoutIsAbsolute = true
    69  	// DefaultHTTPSUpgradeTargetPort is the default upgrade target port.
    70  	DefaultHTTPSUpgradeTargetPort = 443
    71  	// DefaultKeepAlive is the default setting for TCP KeepAlive.
    72  	DefaultKeepAlive = true
    73  	// DefaultKeepAlivePeriod is the default time to keep tcp connections open.
    74  	DefaultKeepAlivePeriod = 3 * time.Minute
    75  	// DefaultShutdownGracePeriod is the default shutdown grace period.
    76  	DefaultShutdownGracePeriod = 30 * time.Second
    77  	// DefaultHealthzFailureThreshold is the default healthz failure threshold.
    78  	DefaultHealthzFailureThreshold = 3
    79  	// DefaultViewBufferPoolSize is the default buffer pool size.
    80  	DefaultViewBufferPoolSize = 256
    81  )
    82  
    83  const (
    84  	// LenSessionID is the byte length of a session id.
    85  	LenSessionID = 64
    86  	// LenSessionIDBase64 is the length of a session id base64 encoded.
    87  	LenSessionIDBase64 = 88
    88  )