handlers

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package handlers //

Package handlers //

Package handlers //

Package handlers //

Package handlers //

Package handlers //

Package handlers //

Package handlers //

Package handlers //

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyUserID = errors.New(`missing "userId" in request payload`)

ErrEmptyUserID is a constant error if userId is omitted from the request

Functions

func Activate added in v0.12.0

func Activate(w http.ResponseWriter, r *http.Request)

Activate makes feature and experiment decisions for the selected query parameters.

func NotificationEventSteamHandler added in v0.14.0

func NotificationEventSteamHandler(w http.ResponseWriter, r *http.Request)

NotificationEventSteamHandler implements the http.Handler interface.

func OptimizelyConfig added in v0.12.0

func OptimizelyConfig(w http.ResponseWriter, r *http.Request)

OptimizelyConfig returns the entire OptimizelyConfig object directly from the SDK

func Override added in v0.12.0

func Override(w http.ResponseWriter, r *http.Request)

Override is used to set forced variations for a given experiment or feature test

func ParseRequestBody

func ParseRequestBody(r *http.Request, v interface{}) error

ParseRequestBody reads the request body from the request and unmarshals it into the provided interface. Note that we're sanitizing the returned error so that it is not leaked back to the requestor.

func RenderError

func RenderError(err error, status int, w http.ResponseWriter, r *http.Request)

RenderError sets the request status and renders the error message.

func TrackEvent added in v0.12.0

func TrackEvent(w http.ResponseWriter, r *http.Request)

TrackEvent - track a given event for the current user

Types

type ActivateBody added in v0.12.0

type ActivateBody struct {
	UserID         string                 `json:"userId"`
	UserAttributes map[string]interface{} `json:"userAttributes"`
}

ActivateBody defines the request body for an activation

type Admin

type Admin struct {
	Config config.AgentConfig
	Info   Info
}

Admin is holding info to pass to admin handlers

func NewAdmin

func NewAdmin(conf config.AgentConfig) *Admin

NewAdmin initializes admin

func (Admin) AppConfig added in v0.12.0

func (a Admin) AppConfig(w http.ResponseWriter, r *http.Request)

AppConfig returns the agent configuration

func (Admin) AppInfo

func (a Admin) AppInfo(w http.ResponseWriter, r *http.Request)

AppInfo returns custom app-info

func (Admin) AppInfoHeader

func (a Admin) AppInfoHeader(next http.Handler) http.Handler

AppInfoHeader adds custom app-info to the response header

func (Admin) Metrics

func (a Admin) Metrics(w http.ResponseWriter, r *http.Request)

Metrics returns expvar info

type ClientCredentials added in v0.12.0

type ClientCredentials struct {
	ID         string
	TTL        time.Duration
	SecretHash []byte
	SDKKeys    []string
}

ClientCredentials has all info for client credentials

type ClientCredentialsError added in v0.13.0

type ClientCredentialsError struct {
	ErrorCode        string `json:"error"`
	ErrorDescription string `json:"error_description,omitempty"`
}

ClientCredentialsError is the response body returned when the provided client credentials are invalid

func (*ClientCredentialsError) Error added in v0.13.0

func (err *ClientCredentialsError) Error() string

type DatafileUpdateData

type DatafileUpdateData struct {
	Revision    int32  `json:"revision"`
	OriginURL   string `json:"origin_url"`
	CDNUrl      string `json:"cdn_url"`
	Environment string `json:"environment"`
}

DatafileUpdateData model which represents data specific to datafile update

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

ErrorResponse Model

type Info added in v0.12.0

type Info struct {
	Version string `json:"version,omitempty"`
	Author  string `json:"author,omitempty"`
	AppName string `json:"app_name,omitempty"`
	Uptime  string `json:"uptime"`
	Host    string `json:"host,omitempty"`
}

Info holds the detail to support the info endpoint

type JSON

type JSON map[string]interface{}

JSON is a map alias, just for convenience

type MessageChan added in v0.12.0

type MessageChan chan []byte

A MessageChan is a channel of bytes Each http handler call creates a new channel and pumps decision service messages onto it.

type OAuthHandler added in v0.12.0

type OAuthHandler struct {
	ClientCredentials map[string]ClientCredentials
	// contains filtered or unexported fields
}

OAuthHandler provides handler for auth

func NewOAuthHandler added in v0.12.0

func NewOAuthHandler(authConfig *config.ServiceAuthConfig) *OAuthHandler

NewOAuthHandler creates new handler for auth

func (*OAuthHandler) CreateAPIAccessToken added in v0.13.0

func (h *OAuthHandler) CreateAPIAccessToken(w http.ResponseWriter, r *http.Request)

CreateAPIAccessToken returns a JWT access token for the API service

func (*OAuthHandler) CreateAdminAccessToken added in v0.13.0

func (h *OAuthHandler) CreateAdminAccessToken(w http.ResponseWriter, r *http.Request)

CreateAdminAccessToken returns a JWT access token for the Admin service

type OptlyMessage

type OptlyMessage struct {
	ProjectID int64              `json:"project_id"`
	Timestamp int64              `json:"timestamp"`
	Event     string             `json:"event"`
	Data      DatafileUpdateData `json:"data"`
}

OptlyMessage model which represents any message received from Optimizely

type OptlyWebhookHandler

type OptlyWebhookHandler struct {
	ProjectMap map[int64]config.WebhookProject
	// contains filtered or unexported fields
}

OptlyWebhookHandler handles incoming messages from Optimizely

func NewWebhookHandler

func NewWebhookHandler(optlyCache optimizely.Cache, projectMap map[int64]config.WebhookProject) *OptlyWebhookHandler

NewWebhookHandler returns a new instance of OptlyWebhookHandler

func (*OptlyWebhookHandler) HandleWebhook

func (h *OptlyWebhookHandler) HandleWebhook(w http.ResponseWriter, r *http.Request)

HandleWebhook handles incoming webhook messages from Optimizely application

type OverrideBody added in v0.12.0

type OverrideBody struct {
	UserID        string `json:"userId"`
	ExperimentKey string `json:"experimentKey"`
	VariationKey  string `json:"variationKey"`
}

OverrideBody defines the request body for an override

Jump to

Keyboard shortcuts

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