middleware

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StreamIdKey = "stream-id"
)

Variables

View Source
var AllowAllCors = middleware.CORSWithConfig(middleware.CORSConfig{
	AllowOrigins:  []string{"*"},
	AllowHeaders:  []string{"*", "Authorization"},
	AllowMethods:  []string{"*"},
	ExposeHeaders: []string{"*"},
})
View Source
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.

type SPAuthValidator

type SPAuthValidator func(string, string, echo.Context) (bool, error)

SPAuthValidator defines a function to validate SPAuth credentials.

Jump to

Keyboard shortcuts

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