Documentation
¶
Index ¶
- func ConvertToType[T any](obj any) (T, error)
- func DecodeJWTUnverified(token string) (map[string]interface{}, error)
- func ExtractBearerToken(c *gin.Context) (string, error)
- func GetCookieValue(c *gin.Context, cookieName string) string
- func GetPatternedURL(c *gin.Context) string
- func GetRequestBody(c *gin.Context) (string, error)
- func TransformToLedgerId(input string) string
- type JwtCookieInfo
- type PolicyMap
- type UsageFlowAPI
- func (u *UsageFlowAPI) ExecuteFulfillRequestWithMetadata(ledgerId, method, url string, metadata map[string]interface{}, c *gin.Context) (bool, error)
- func (u *UsageFlowAPI) ExecuteRequestWithMetadata(ledgerId, method, url string, metadata map[string]interface{}, c *gin.Context, ...) (bool, error)
- func (u *UsageFlowAPI) FetchApiConfig() ([]config.ApiConfigStrategy, error)
- func (u *UsageFlowAPI) FetchApplicationConfig() (config.ApplicationConfigResponse, error)
- func (u *UsageFlowAPI) FetchBlockedEndpoints() error
- func (u *UsageFlowAPI) GetUserPrefix(c *gin.Context, method, url string) (string, bool)
- func (u *UsageFlowAPI) GuessLedgerId(c *gin.Context) string
- func (u *UsageFlowAPI) RequestInterceptor() gin.HandlerFunc
- func (u *UsageFlowAPI) StartConfigUpdater()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToType ¶ added in v2.2.0
func DecodeJWTUnverified ¶
DecodeJWTUnverified decodes a JWT without verifying its signature
func ExtractBearerToken ¶
ExtractBearerToken extracts the bearer token from the Authorization header
func GetCookieValue ¶ added in v2.4.0
GetCookieValue extracts a specific cookie value from the Cookie header It handles both "cookie" and "Cookie" header names (case-insensitive)
func GetPatternedURL ¶
GetPatternedURL returns a standardized URL pattern for the current request
func GetRequestBody ¶
GetRequestBody reads and returns the request body as a string
func TransformToLedgerId ¶
TransformToLedgerId converts an input string to a valid ledger ID format
Types ¶
type JwtCookieInfo ¶ added in v2.4.0
JwtCookieInfo represents parsed JWT cookie information
func ParseJwtCookieField ¶ added in v2.4.0
func ParseJwtCookieField(fieldName string) *JwtCookieInfo
ParseJwtCookieField parses JWT cookie field format: '[technique=jwt]cookieName[pick=claim]' Returns the cookie name and claim if the format matches, otherwise returns nil
type PolicyMap ¶
type PolicyMap map[string]*config.ApplicationEndpointPolicy
type UsageFlowAPI ¶
type UsageFlowAPI struct {
APIKey string `json:"apiKey"`
ApplicationId string `json:"applicationId"`
ApiConfig []config.ApiConfigStrategy `json:"apiConfig"`
BlockedEndpoints map[string]bool `json:"blockedEndpoints"`
ApplicationEndpointPolicies *config.PolicyResponse `json:"applicationEndpointPolicies"`
WhitelistEndpoints []config.Route `json:"whitelistEndpoints"`
MonitoringPaths []config.Route `json:"monitoringPaths"`
// contains filtered or unexported fields
}
func (*UsageFlowAPI) ExecuteFulfillRequestWithMetadata ¶
func (u *UsageFlowAPI) ExecuteFulfillRequestWithMetadata(ledgerId, method, url string, metadata map[string]interface{}, c *gin.Context) (bool, error)
ExecuteFulfillRequestWithMetadata executes the fulfill request after the main request is processed
func (*UsageFlowAPI) ExecuteRequestWithMetadata ¶
func (u *UsageFlowAPI) ExecuteRequestWithMetadata(ledgerId, method, url string, metadata map[string]interface{}, c *gin.Context, rateLimited bool) (bool, error)
ExecuteRequestWithMetadata executes the initial allocation request
func (*UsageFlowAPI) FetchApiConfig ¶
func (u *UsageFlowAPI) FetchApiConfig() ([]config.ApiConfigStrategy, error)
func (*UsageFlowAPI) FetchApplicationConfig ¶ added in v2.2.0
func (u *UsageFlowAPI) FetchApplicationConfig() (config.ApplicationConfigResponse, error)
func (*UsageFlowAPI) FetchBlockedEndpoints ¶ added in v2.1.0
func (u *UsageFlowAPI) FetchBlockedEndpoints() error
func (*UsageFlowAPI) GetUserPrefix ¶
GetUserPrefix attempts to extract a user identifier prefix based on the API configuration
func (*UsageFlowAPI) GuessLedgerId ¶
func (u *UsageFlowAPI) GuessLedgerId(c *gin.Context) string
GuessLedgerId attempts to extract a ledger ID from various sources
func (*UsageFlowAPI) RequestInterceptor ¶
func (u *UsageFlowAPI) RequestInterceptor() gin.HandlerFunc
RequestInterceptor creates a Gin middleware for intercepting requests
func (*UsageFlowAPI) StartConfigUpdater ¶
func (u *UsageFlowAPI) StartConfigUpdater()
StartConfigUpdater begins periodic updates of the API configuration