server

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const TokenClaimsKey contextKey = "tokenClaims"

Variables

View Source
var (
	DbPlugins  = make(map[string]easyrest.DBPlugin)
	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

func AccessLogMiddleware(next http.Handler) http.Handler

AccessLogMiddleware logs incoming HTTP requests if enabled.

func Authenticate

func Authenticate(r *http.Request) (string, *http.Request, error)

Authenticate extracts and validates the JWT token.

func BuildPluginContext added in v0.1.1

func BuildPluginContext(r *http.Request) map[string]any

BuildPluginContext extracts context variables from the HTTP request.

func CheckScope added in v0.1.1

func CheckScope(claims jwt.MapClaims, required string) bool

CheckScope verifies if the claims contain the required scope.

func DecodeTokenWithoutValidation

func DecodeTokenWithoutValidation(tokenStr string) (jwt.MapClaims, error)

DecodeTokenWithoutValidation decodes a JWT token without validating its signature.

func GetConfig added in v0.3.1

func GetConfig() config.Config

GetConfig loads configuration only once.

func IsAllowedFunction added in v0.1.1

func IsAllowedFunction(item string) bool

IsAllowedFunction checks if the provided function name is allowed.

func LoadDBPlugins added in v0.1.1

func LoadDBPlugins()

LoadDBPlugins loads all configured database plugins.

func ParseCSV added in v0.1.1

func ParseCSV(s string) []string

ParseCSV splits a comma-separated string.

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 Run

func Run(config config.Config)

Run starts the HTTP server.

func SetConfig added in v0.3.1

func SetConfig(newConfig config.Config)

SetConfig sets a new configuration.

func SetupRouter

func SetupRouter() *mux.Router

SetupRouter initializes the router and endpoints.

Types

This section is empty.

Jump to

Keyboard shortcuts

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