middleware

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCORSConfig = CORSConfig{
	AllowOrigin:  "*",
	AllowMethods: []string{"GET", "POST", "PUT", "DELETE"},
	AllowHeaders: []string{"Content-Type", "Authorization"},
}

DefaultCORSConfig provides a default configuration for CORS.

View Source
var DefaultLoggingConfig = LoggingConfig{
	Enabled: true,
}

DefaultLoggingConfig provides a default configuration for Logging.

View Source
var DefaultRecoveryConfig = RecoveryConfig{
	Enabled: true,
}

DefaultRecoveryConfig provides a default configuration for Recovery.

View Source
var DefaultRequestIDConfig = RequestIDConfig{
	Enabled: true,
	Header:  "X-Request-ID",
}

DefaultRequestIDConfig provides a default configuration for RequestID.

Functions

func CORS

func CORS(config CORSConfig) pulse.Middleware

CORS is a middleware function that handles Cross-Origin Resource Sharing (CORS) settings.

func DefaultCORS

func DefaultCORS() pulse.Middleware

DefaultCORS is a middleware function that uses the default CORS settings.

func DefaultLogging

func DefaultLogging() pulse.Middleware

DefaultLogging is a middleware function that uses the default Logging settings.

func DefaultRecovery

func DefaultRecovery() pulse.Middleware

DefaultRecovery is a middleware function that uses the default Recovery settings.

func DefaultRequestID

func DefaultRequestID() pulse.Middleware

DefaultRequestID is a middleware function that uses the default RequestID settings.

func Logging

func Logging(config LoggingConfig) pulse.Middleware

Logging is a middleware function that logs the request details and execution time.

func Recovery

func Recovery(config RecoveryConfig) pulse.Middleware

Recovery is a middleware function that handles panics and ensures the server does not crash.

func RequestID

func RequestID(config RequestIDConfig) pulse.Middleware

RequestID is a middleware function that assigns a unique ID to each request for tracking and logging purposes.

Types

type CORSConfig

type CORSConfig struct {
	AllowOrigin  string   // Allowed origin for CORS
	AllowMethods []string // Allowed HTTP methods for CORS
	AllowHeaders []string // Allowed headers for CORS
}

CORSConfig defines the configuration for the CORS middleware.

type LoggingConfig

type LoggingConfig struct {
	Enabled bool // Flag to enable or disable logging
}

LoggingConfig defines the configuration for the Logging middleware.

type RecoveryConfig

type RecoveryConfig struct {
	Enabled bool // Flag to enable or disable recovery
}

RecoveryConfig defines the configuration for the Recovery middleware.

type RequestIDConfig

type RequestIDConfig struct {
	Enabled bool   // Flag to enable or disable request ID generation
	Header  string // Header name to store the request ID
}

RequestIDConfig defines the configuration for the RequestID middleware.

Jump to

Keyboard shortcuts

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