Documentation
¶
Index ¶
- Constants
- Variables
- func AccessLogMiddleware(next http.Handler) http.Handler
- func Authenticate(r *http.Request) (string, *http.Request, error)
- func BuildPluginContext(r *http.Request) map[string]any
- func CheckScope(claims jwt.MapClaims, required string) bool
- func DecodeTokenWithoutValidation(tokenStr string) (jwt.MapClaims, error)
- func GetConfig() config.Config
- func InitOtel(otelCfg config.OtelConfig) (shutdown func(context.Context) error, err error)
- func IsAllowedFunction(item string) bool
- func LoadPlugins()
- func ParseCSV(s string) []string
- func ParseWhereClause(values map[string][]string, flatCtx map[string]string, ...) (map[string]any, error)
- func ReloadConfig()
- func ResetClaimsCache()
- func Run(conf config.Config)
- func SetConfig(newConfig config.Config)
- func SetupRouter() chi.Router
- func StopPlugins()
- type Operation
- type Parameter
- type PathItem
- type PreservedPluginFactory
- type SwaggerInfo
- type SwaggerSpec
Constants ¶
const TokenClaimsKey contextKey = "tokenClaims"
Variables ¶
var ( DbPlugins atomic.Pointer[map[string]easyrest.DBPlugin] CachePlugins atomic.Pointer[map[string]easyrest.CachePlugin] AuthPlugins atomic.Pointer[map[string]easyrest.AuthPlugin] AuthSecurityDefinitions atomic.Pointer[map[string]map[string]any] PreservedCachePlugins map[string]PreservedPluginFactory[easyrest.CachePlugin] PreservedDbPlugins map[string]PreservedPluginFactory[easyrest.DBPlugin] PreservedAuthPlugins map[string]PreservedPluginFactory[easyrest.AuthPlugin] AllowedOps = map[string]string{ "eq": "=", "neq": "!=", "lt": "<", "lte": "<=", "gt": ">", "gte": ">=", "like": "LIKE", "ilike": "ILIKE", "is": "IS", "in": "IN", } )
Global configuration and dbPlugins loaded only once.
Functions ¶
func AccessLogMiddleware ¶ added in v0.1.1
AccessLogMiddleware logs incoming HTTP requests if enabled.
func Authenticate ¶
Authenticate extracts and validates the JWT token.
func BuildPluginContext ¶ added in v0.1.1
BuildPluginContext extracts context variables from the HTTP request.
func CheckScope ¶ added in v0.1.1
CheckScope verifies if the claims contain the required scope.
func IsAllowedFunction ¶ added in v0.1.1
IsAllowedFunction checks if the provided function name is allowed.
func LoadPlugins ¶ added in v0.6.0
func LoadPlugins()
LoadPlugins loads all configured database and cache plugins.
func ParseWhereClause ¶ added in v0.1.1
func ParseWhereClause(values map[string][]string, flatCtx map[string]string, pluginCtx map[string]any) (map[string]any, error)
ParseWhereClause converts query parameters starting with "where." into a map, performing context substitution for values.
func ReloadConfig ¶ added in v0.5.0
func ReloadConfig()
func ResetClaimsCache ¶ added in v0.8.5
func ResetClaimsCache()
func StopPlugins ¶ added in v0.6.0
func StopPlugins()
Types ¶
type Operation ¶ added in v0.8.1
type Operation struct {
Summary string `json:"summary"`
Description string `json:"description"`
Parameters []Parameter `json:"parameters"`
Security []map[string]any `json:"security"`
Responses map[string]any `json:"responses"`
}
Operation represents a Swagger operation object.
type Parameter ¶ added in v0.8.1
type Parameter struct {
Name string `json:"name"`
In string `json:"in"`
Description string `json:"description"`
Required bool `json:"required"`
Type string `json:"type,omitempty"`
Items any `json:"items,omitempty"`
Schema any `json:"schema,omitempty"`
CollectionFormat string `json:"collectionFormat,omitempty"`
}
Parameter represents a Swagger parameter object.
type PathItem ¶ added in v0.8.1
type PathItem struct {
Get *Operation `json:"get,omitempty"`
Post *Operation `json:"post,omitempty"`
Patch *Operation `json:"patch,omitempty"`
Delete *Operation `json:"delete,omitempty"`
}
PathItem represents a Swagger path item object.
type PreservedPluginFactory ¶ added in v0.9.0
type PreservedPluginFactory[T any] func() T
type SwaggerInfo ¶ added in v0.8.1
type SwaggerSpec ¶ added in v0.8.1
type SwaggerSpec struct {
Swagger string `json:"swagger"`
Info SwaggerInfo `json:"info"`
Host string `json:"host"`
BasePath string `json:"basePath"`
Schemes []string `json:"schemes"`
Consumes []string `json:"consumes"`
Produces []string `json:"produces"`
Definitions map[string]any `json:"definitions"`
SecurityDefinitions map[string]any `json:"securityDefinitions"`
Paths map[string]any `json:"paths"`
}
SwaggerSpec represents the Swagger 2.0 specification structure.