Documentation
¶
Index ¶
- Constants
- func DeleteSession(name string, c echo.Context) error
- func ErrorHandler(e *echo.Echo) echo.HTTPErrorHandler
- func GetSession(name string, c echo.Context) (*sessions.Session, error)
- func NewAuthenticationMiddleware(authenticator Authenticator, options ...AuthenticationMiddlewareOption) echo.MiddlewareFunc
- func NewEchoSlogLogger(logger *slog.Logger, level *slog.LevelVar) echo.Logger
- func NewSessionMiddleware(sessionStore sessions.Store) echo.MiddlewareFunc
- func NewTestDeleteRequest(e *echo.Echo, path string) (echo.Context, *httptest.ResponseRecorder)
- func NewTestGetRequest(e *echo.Echo, path string) (echo.Context, *httptest.ResponseRecorder)
- func NewTestPatchJSONRequest(e *echo.Echo, path string, body string) (echo.Context, *httptest.ResponseRecorder)
- func NewTestPostJSONRequest(e *echo.Echo, path string, body string) (echo.Context, *httptest.ResponseRecorder)
- func NewTestPutJSONRequest(e *echo.Echo, path string, body string) (echo.Context, *httptest.ResponseRecorder)
- func PanicLogger(c echo.Context, err error, stack []byte) error
- func RequestLogger() echo.MiddlewareFunc
- func RequestLoggerWithConfig(config RequestLoggerConfig) echo.MiddlewareFunc
- func RequireAuthenticated() echo.MiddlewareFunc
- func RequirePermission(permission string, orPermission ...string) echo.MiddlewareFunc
- func RequirePermissions(permissions []string, orPermissions ...[]string) echo.MiddlewareFunc
- func WithAuthenticatedUserCallback(callback func(AuthenticatedUser) error) func(*AuthenticationMiddlewareOptions)
- type Auth0Authenticator
- func (a *Auth0Authenticator) AuthenticateRequest(c echo.Context) error
- func (a *Auth0Authenticator) GetAuthCodeURL(c echo.Context) (*url.URL, error)
- func (a *Auth0Authenticator) GetAuthenticatedUser(c echo.Context) (*AuthenticatedUser, error)
- func (a *Auth0Authenticator) HandleAuthenticationCallback(c echo.Context) (bool, error)
- func (a *Auth0Authenticator) HandleNotAuthenticated(c echo.Context) error
- func (a *Auth0Authenticator) IsAuthenticated(c echo.Context) (bool, error)
- func (a *Auth0Authenticator) Login(c echo.Context) error
- func (a *Auth0Authenticator) Logout(c echo.Context) error
- type Auth0AuthenticatorOption
- type Auth0Config
- type Auth0CustomClaims
- type Auth0JWTAuthenticator
- func (a *Auth0JWTAuthenticator) AuthenticateRequest(c echo.Context) error
- func (a *Auth0JWTAuthenticator) GetAuthenticatedUser(c echo.Context) (*AuthenticatedUser, error)
- func (a *Auth0JWTAuthenticator) HandleNotAuthenticated(c echo.Context) error
- func (a *Auth0JWTAuthenticator) IsAuthenticated(c echo.Context) (bool, error)
- type Auth0JWTAuthenticatorOption
- type AuthenticatedUser
- type AuthenticationMiddlewareOption
- type AuthenticationMiddlewareOptions
- type Authenticator
- type CustomValidator
- type EchoSlogLogger
- func (l EchoSlogLogger) Debug(i ...interface{})
- func (l EchoSlogLogger) Debugf(format string, args ...interface{})
- func (l EchoSlogLogger) Debugj(j echolog.JSON)
- func (l EchoSlogLogger) Error(i ...interface{})
- func (l EchoSlogLogger) Errorf(format string, args ...interface{})
- func (l EchoSlogLogger) Errorj(j echolog.JSON)
- func (l EchoSlogLogger) Fatal(i ...interface{})
- func (l EchoSlogLogger) Fatalf(format string, args ...interface{})
- func (l EchoSlogLogger) Fatalj(j echolog.JSON)
- func (l EchoSlogLogger) Info(i ...interface{})
- func (l EchoSlogLogger) Infof(format string, args ...interface{})
- func (l EchoSlogLogger) Infoj(j echolog.JSON)
- func (l *EchoSlogLogger) Level() echolog.Lvl
- func (l *EchoSlogLogger) Output() io.Writer
- func (l EchoSlogLogger) Panic(i ...interface{})
- func (l EchoSlogLogger) Panicf(format string, args ...interface{})
- func (l EchoSlogLogger) Panicj(j echolog.JSON)
- func (l *EchoSlogLogger) Prefix() string
- func (l *EchoSlogLogger) Print(i ...interface{})
- func (l *EchoSlogLogger) Printf(format string, args ...interface{})
- func (l EchoSlogLogger) Printj(j echolog.JSON)
- func (l *EchoSlogLogger) SetHeader(h string)
- func (l *EchoSlogLogger) SetLevel(v echolog.Lvl)
- func (l *EchoSlogLogger) SetOutput(w io.Writer)
- func (l *EchoSlogLogger) SetPrefix(p string)
- func (l EchoSlogLogger) Warn(i ...interface{})
- func (l EchoSlogLogger) Warnf(format string, args ...interface{})
- func (l EchoSlogLogger) Warnj(j echolog.JSON)
- type EntraIDCustomClaims
- type EntraIDJWTAuthenticator
- func (a *EntraIDJWTAuthenticator) AuthenticateRequest(c echo.Context) error
- func (a *EntraIDJWTAuthenticator) GetAuthenticatedUser(c echo.Context) (*AuthenticatedUser, error)
- func (a *EntraIDJWTAuthenticator) HandleNotAuthenticated(c echo.Context) error
- func (a *EntraIDJWTAuthenticator) IsAuthenticated(c echo.Context) (bool, error)
- type FakeAuthenticator
- func (f *FakeAuthenticator) AuthenticateRequest(c echo.Context) error
- func (f *FakeAuthenticator) GetAuthenticatedUser(c echo.Context) (*AuthenticatedUser, error)
- func (f *FakeAuthenticator) HandleNotAuthenticated(c echo.Context) error
- func (f *FakeAuthenticator) IsAuthenticated(c echo.Context) (bool, error)
- type LayoutModelFunc
- type LogWriter
- type Renderer
- type RequestLoggerConfig
Constants ¶
const CONTEXT_KEY_SESSION_STORE = "fx-session-store"
Variables ¶
This section is empty.
Functions ¶
func DeleteSession ¶
func ErrorHandler ¶ added in v0.9.0
func ErrorHandler(e *echo.Echo) echo.HTTPErrorHandler
ErrorHandler returns a custom HTTP error handler that wraps non-HTTPError errors in HTTPError with status 500 and includes request ID in the response message, then delegates to Echo's default error handler to send the response.
func NewAuthenticationMiddleware ¶
func NewAuthenticationMiddleware(authenticator Authenticator, options ...AuthenticationMiddlewareOption) echo.MiddlewareFunc
func NewEchoSlogLogger ¶
func NewSessionMiddleware ¶
func NewTestDeleteRequest ¶ added in v0.10.0
func NewTestDeleteRequest(e *echo.Echo, path string) (echo.Context, *httptest.ResponseRecorder)
NewTestDeleteRequest creates a test DELETE request
func NewTestGetRequest ¶ added in v0.10.0
func NewTestGetRequest(e *echo.Echo, path string) (echo.Context, *httptest.ResponseRecorder)
NewTestGetRequest creates a test GET request with the given path
func NewTestPatchJSONRequest ¶ added in v0.10.0
func NewTestPatchJSONRequest(e *echo.Echo, path string, body string) (echo.Context, *httptest.ResponseRecorder)
NewTestPatchJSONRequest creates a test PATCH request with JSON body
func NewTestPostJSONRequest ¶ added in v0.10.0
func NewTestPostJSONRequest(e *echo.Echo, path string, body string) (echo.Context, *httptest.ResponseRecorder)
NewTestPostJSONRequest creates a test POST request with JSON body
func NewTestPutJSONRequest ¶ added in v0.10.0
func NewTestPutJSONRequest(e *echo.Echo, path string, body string) (echo.Context, *httptest.ResponseRecorder)
NewTestPutJSONRequest creates a test PUT request with JSON body
func PanicLogger ¶ added in v0.9.0
PanicLogger logs panics at ERROR level with error message, stack trace, URI, and method. This function is meant to be used as the LogErrorFunc in echomiddleware.RecoverConfig.
func RequestLogger ¶ added in v0.9.0
func RequestLogger() echo.MiddlewareFunc
RequestLogger returns a middleware that logs all HTTP requests with structured logging. All requests are logged at INFO level by default.
func RequestLoggerWithConfig ¶ added in v0.9.0
func RequestLoggerWithConfig(config RequestLoggerConfig) echo.MiddlewareFunc
RequestLoggerWithConfig returns a middleware that logs all HTTP requests with structured logging. Paths specified in config.DebugPaths are logged at DEBUG level, all others at INFO level.
func RequireAuthenticated ¶ added in v0.10.0
func RequireAuthenticated() echo.MiddlewareFunc
func RequirePermission ¶ added in v0.10.0
func RequirePermissions ¶ added in v0.10.0
func WithAuthenticatedUserCallback ¶
func WithAuthenticatedUserCallback(callback func(AuthenticatedUser) error) func(*AuthenticationMiddlewareOptions)
Types ¶
type Auth0Authenticator ¶
type Auth0Authenticator struct {
// contains filtered or unexported fields
}
func (*Auth0Authenticator) AuthenticateRequest ¶ added in v0.10.0
func (a *Auth0Authenticator) AuthenticateRequest(c echo.Context) error
func (*Auth0Authenticator) GetAuthCodeURL ¶
func (a *Auth0Authenticator) GetAuthCodeURL(c echo.Context) (*url.URL, error)
func (*Auth0Authenticator) GetAuthenticatedUser ¶
func (a *Auth0Authenticator) GetAuthenticatedUser(c echo.Context) (*AuthenticatedUser, error)
func (*Auth0Authenticator) HandleAuthenticationCallback ¶
func (a *Auth0Authenticator) HandleAuthenticationCallback(c echo.Context) (bool, error)
func (*Auth0Authenticator) HandleNotAuthenticated ¶
func (a *Auth0Authenticator) HandleNotAuthenticated(c echo.Context) error
func (*Auth0Authenticator) IsAuthenticated ¶
func (a *Auth0Authenticator) IsAuthenticated(c echo.Context) (bool, error)
func (*Auth0Authenticator) Login ¶
func (a *Auth0Authenticator) Login(c echo.Context) error
func (*Auth0Authenticator) Logout ¶
func (a *Auth0Authenticator) Logout(c echo.Context) error
type Auth0AuthenticatorOption ¶
type Auth0AuthenticatorOption func(*Auth0Authenticator)
type Auth0Config ¶
type Auth0CustomClaims ¶ added in v0.9.0
type Auth0CustomClaims struct {
Name string `json:"name"`
GivenName string `json:"given_name"`
FamilyName string `json:"family_name"`
MiddleName string `json:"middle_name"`
Nickname string `json:"nickname"`
PreferredUsername string `json:"preferred_username"`
Email string `json:"email"`
EmailVerified bool `json:"email_verified"`
Picture string `json:"picture"`
UpdatedAt int64 `json:"updated_at"`
Permissions []string `json:"permissions"`
}
type Auth0JWTAuthenticator ¶ added in v0.9.0
type Auth0JWTAuthenticator struct {
// contains filtered or unexported fields
}
func (*Auth0JWTAuthenticator) AuthenticateRequest ¶ added in v0.10.0
func (a *Auth0JWTAuthenticator) AuthenticateRequest(c echo.Context) error
func (*Auth0JWTAuthenticator) GetAuthenticatedUser ¶ added in v0.9.0
func (a *Auth0JWTAuthenticator) GetAuthenticatedUser(c echo.Context) (*AuthenticatedUser, error)
func (*Auth0JWTAuthenticator) HandleNotAuthenticated ¶ added in v0.9.0
func (a *Auth0JWTAuthenticator) HandleNotAuthenticated(c echo.Context) error
func (*Auth0JWTAuthenticator) IsAuthenticated ¶ added in v0.9.0
func (a *Auth0JWTAuthenticator) IsAuthenticated(c echo.Context) (bool, error)
type Auth0JWTAuthenticatorOption ¶ added in v0.9.0
type Auth0JWTAuthenticatorOption func(*Auth0JWTAuthenticator)
type AuthenticatedUser ¶
type AuthenticationMiddlewareOption ¶ added in v0.10.0
type AuthenticationMiddlewareOption func(*AuthenticationMiddlewareOptions)
type AuthenticationMiddlewareOptions ¶ added in v0.10.0
type AuthenticationMiddlewareOptions struct {
AuthenticatedUserCallback func(AuthenticatedUser) error
}
type Authenticator ¶
type Authenticator interface {
AuthenticateRequest(c echo.Context) error
GetAuthenticatedUser(c echo.Context) (*AuthenticatedUser, error)
IsAuthenticated(c echo.Context) (bool, error)
HandleNotAuthenticated(c echo.Context) error
}
func GetAuthenticator ¶
func GetAuthenticator(c echo.Context) (Authenticator, error)
func NewAuth0Authenticator ¶
func NewAuth0Authenticator(config Auth0Config) (Authenticator, error)
func NewAuth0JWTAuthenticator ¶ added in v0.9.0
func NewAuth0JWTAuthenticator(config Auth0Config) (Authenticator, error)
func NewEntraIDJWTAuthenticator ¶ added in v0.9.0
func NewEntraIDJWTAuthenticator(tenantID, audience string) (Authenticator, error)
NewEntraIDJWTAuthenticator creates a JWT authenticator for Microsoft Entra ID
type CustomValidator ¶ added in v0.9.0
type CustomValidator struct {
// contains filtered or unexported fields
}
CustomValidator wraps the validator for Echo
func NewValidator ¶ added in v0.9.0
func NewValidator() *CustomValidator
NewValidator creates a new validator instance
func (*CustomValidator) Validate ¶ added in v0.9.0
func (cv *CustomValidator) Validate(i interface{}) error
Validate implements Echo's Validator interface
type EchoSlogLogger ¶
type EchoSlogLogger struct {
// contains filtered or unexported fields
}
func (EchoSlogLogger) Debug ¶
func (l EchoSlogLogger) Debug(i ...interface{})
func (EchoSlogLogger) Debugf ¶
func (l EchoSlogLogger) Debugf(format string, args ...interface{})
func (EchoSlogLogger) Debugj ¶
func (l EchoSlogLogger) Debugj(j echolog.JSON)
func (EchoSlogLogger) Error ¶
func (l EchoSlogLogger) Error(i ...interface{})
func (EchoSlogLogger) Errorf ¶
func (l EchoSlogLogger) Errorf(format string, args ...interface{})
func (EchoSlogLogger) Errorj ¶
func (l EchoSlogLogger) Errorj(j echolog.JSON)
func (EchoSlogLogger) Fatal ¶
func (l EchoSlogLogger) Fatal(i ...interface{})
func (EchoSlogLogger) Fatalf ¶
func (l EchoSlogLogger) Fatalf(format string, args ...interface{})
func (EchoSlogLogger) Fatalj ¶
func (l EchoSlogLogger) Fatalj(j echolog.JSON)
func (EchoSlogLogger) Info ¶
func (l EchoSlogLogger) Info(i ...interface{})
func (EchoSlogLogger) Infof ¶
func (l EchoSlogLogger) Infof(format string, args ...interface{})
func (EchoSlogLogger) Infoj ¶
func (l EchoSlogLogger) Infoj(j echolog.JSON)
func (*EchoSlogLogger) Level ¶
func (l *EchoSlogLogger) Level() echolog.Lvl
func (*EchoSlogLogger) Output ¶
func (l *EchoSlogLogger) Output() io.Writer
func (EchoSlogLogger) Panic ¶
func (l EchoSlogLogger) Panic(i ...interface{})
func (EchoSlogLogger) Panicf ¶
func (l EchoSlogLogger) Panicf(format string, args ...interface{})
func (EchoSlogLogger) Panicj ¶
func (l EchoSlogLogger) Panicj(j echolog.JSON)
func (*EchoSlogLogger) Prefix ¶
func (l *EchoSlogLogger) Prefix() string
func (*EchoSlogLogger) Print ¶
func (l *EchoSlogLogger) Print(i ...interface{})
func (*EchoSlogLogger) Printf ¶
func (l *EchoSlogLogger) Printf(format string, args ...interface{})
func (EchoSlogLogger) Printj ¶
func (l EchoSlogLogger) Printj(j echolog.JSON)
func (*EchoSlogLogger) SetHeader ¶
func (l *EchoSlogLogger) SetHeader(h string)
func (*EchoSlogLogger) SetLevel ¶
func (l *EchoSlogLogger) SetLevel(v echolog.Lvl)
func (*EchoSlogLogger) SetOutput ¶
func (l *EchoSlogLogger) SetOutput(w io.Writer)
func (*EchoSlogLogger) SetPrefix ¶
func (l *EchoSlogLogger) SetPrefix(p string)
func (EchoSlogLogger) Warn ¶
func (l EchoSlogLogger) Warn(i ...interface{})
func (EchoSlogLogger) Warnf ¶
func (l EchoSlogLogger) Warnf(format string, args ...interface{})
func (EchoSlogLogger) Warnj ¶
func (l EchoSlogLogger) Warnj(j echolog.JSON)
type EntraIDCustomClaims ¶ added in v0.9.0
type EntraIDCustomClaims struct {
Name string `json:"name"`
GivenName string `json:"given_name"`
FamilyName string `json:"family_name"`
MiddleName string `json:"middle_name"`
PreferredUsername string `json:"preferred_username"`
Email string `json:"email"`
Picture string `json:"picture"`
UpdatedAt int64 `json:"updated_at"`
Scp string `json:"scp"`
}
type EntraIDJWTAuthenticator ¶ added in v0.9.0
type EntraIDJWTAuthenticator struct {
// contains filtered or unexported fields
}
func (*EntraIDJWTAuthenticator) AuthenticateRequest ¶ added in v0.10.0
func (a *EntraIDJWTAuthenticator) AuthenticateRequest(c echo.Context) error
func (*EntraIDJWTAuthenticator) GetAuthenticatedUser ¶ added in v0.9.0
func (a *EntraIDJWTAuthenticator) GetAuthenticatedUser(c echo.Context) (*AuthenticatedUser, error)
func (*EntraIDJWTAuthenticator) HandleNotAuthenticated ¶ added in v0.9.0
func (a *EntraIDJWTAuthenticator) HandleNotAuthenticated(c echo.Context) error
func (*EntraIDJWTAuthenticator) IsAuthenticated ¶ added in v0.9.0
func (a *EntraIDJWTAuthenticator) IsAuthenticated(c echo.Context) (bool, error)
type FakeAuthenticator ¶ added in v0.10.0
type FakeAuthenticator struct {
AuthenticateRequestFake func(c echo.Context) error
GetAuthenticatedUserFake func(c echo.Context) (*AuthenticatedUser, error)
IsAuthenticatedFake func(c echo.Context) (bool, error)
HandleNotAuthenticatedFake func(c echo.Context) error
}
func (*FakeAuthenticator) AuthenticateRequest ¶ added in v0.10.0
func (f *FakeAuthenticator) AuthenticateRequest(c echo.Context) error
func (*FakeAuthenticator) GetAuthenticatedUser ¶ added in v0.10.0
func (f *FakeAuthenticator) GetAuthenticatedUser(c echo.Context) (*AuthenticatedUser, error)
func (*FakeAuthenticator) HandleNotAuthenticated ¶ added in v0.10.0
func (f *FakeAuthenticator) HandleNotAuthenticated(c echo.Context) error
func (*FakeAuthenticator) IsAuthenticated ¶ added in v0.10.0
func (f *FakeAuthenticator) IsAuthenticated(c echo.Context) (bool, error)
type LayoutModelFunc ¶
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
func NewRenderer ¶
func NewRenderer(templateFilesPath string, layoutModelFunc LayoutModelFunc) *Renderer
type RequestLoggerConfig ¶ added in v0.9.0
type RequestLoggerConfig struct {
// DebugPaths is a list of paths that should be logged at DEBUG level instead of INFO.
// All other paths will be logged at INFO level.
DebugPaths []string
}
RequestLoggerConfig defines the configuration for the request logger middleware.