Documentation
¶
Index ¶
- Constants
- Variables
- func ConstantEtag() echo.MiddlewareFunc
- func SPAuth(passwords []string) echo.MiddlewareFunc
- func SPAuthWithConfig(config SPAuthConfig) echo.MiddlewareFunc
- func SinglePageApp(fallback string) echo.MiddlewareFunc
- func StreamId(next echo.HandlerFunc) echo.HandlerFunc
- type SPAuthConfig
- type SPAuthValidator
Constants ¶
const (
StreamIdKey = "stream-id"
)
Variables ¶
var AllowAllCors = middleware.CORSWithConfig(middleware.CORSConfig{ AllowOrigins: []string{"*"}, AllowHeaders: []string{"*", "Authorization"}, AllowMethods: []string{"*"}, ExposeHeaders: []string{"*"}, })
var ( // DefaultSPAuthConfig is the default SPAuth middleware config. DefaultSPAuthConfig = SPAuthConfig{ Skipper: middleware.DefaultSkipper, Expiration: expiration, } )
Functions ¶
func ConstantEtag ¶
func ConstantEtag() echo.MiddlewareFunc
ConstantEtag Static files in this project does not change until the server restarts. This middleware writes a constant eTag header into resp when serving static files.
func SPAuth ¶
func SPAuth(passwords []string) echo.MiddlewareFunc
SPAuth returns an SPAuth middleware.
Header example: Authorization: Bearer 00THIS00IS00A00HASH For valid credentials it calls the next handler. For missing or invalid credentials, it sends "401 - Unauthorized" response.
func SPAuthWithConfig ¶
func SPAuthWithConfig(config SPAuthConfig) echo.MiddlewareFunc
SPAuthWithConfig returns an SPAuth middleware with config. See `SPAuth()`.
func SinglePageApp ¶
func SinglePageApp(fallback string) echo.MiddlewareFunc
SinglePageApp acts like nginx try_files: {try_files $uri /index.html}
This is useful when serving a single page application
func StreamId ¶
func StreamId(next echo.HandlerFunc) echo.HandlerFunc
StreamId The stream-id is a randomly generated string used by SSE to identify clients. The headers must include a stream id.
Types ¶
type SPAuthConfig ¶
type SPAuthConfig struct {
// Skipper defines a function to skip middleware.
Skipper middleware.Skipper
Expiration time.Duration
Passwords []string
}
SPAuthConfig defines the config for SPAuth middleware.