handlers

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 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 //

Package handlers //

Package handlers //

Package handlers //

Package handlers //

Package handlers //

Index

Constants

This section is empty.

Variables

This section is empty.

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 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) Health

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

Health displays health status

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
	Secret []byte
}

ClientCredentials has all info for client credentials

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 Experiment

type Experiment struct {
	ID         int32                `json:"id"`
	Key        string               `json:"key"`
	Variations map[string]Variation `json:"variations,omitempty"`
}

Experiment Model

type ExperimentAPI

type ExperimentAPI interface {
	GetExperiment(w http.ResponseWriter, r *http.Request)
	ListExperiments(w http.ResponseWriter, r *http.Request)
}

ExperimentAPI defines the supported experiment apis.

type ExperimentHandler

type ExperimentHandler struct{}

ExperimentHandler implements the ExperimentAPI interface

func (*ExperimentHandler) GetExperiment

func (h *ExperimentHandler) GetExperiment(w http.ResponseWriter, r *http.Request)

GetExperiment - Get requested experiment

func (*ExperimentHandler) ListExperiments

func (h *ExperimentHandler) ListExperiments(w http.ResponseWriter, r *http.Request)

ListExperiments - List all experiments

type Feature

type Feature struct {
	Key       string                 `json:"key"`
	Variables map[string]interface{} `json:"variables,omitempty"`
	ID        int32                  `json:"id,omitempty"`
	Enabled   bool                   `json:"enabled"`
}

Feature Model

type FeatureAPI

type FeatureAPI interface {
	GetFeature(w http.ResponseWriter, r *http.Request)
	ListFeatures(w http.ResponseWriter, r *http.Request)
}

FeatureAPI defines the supported feature apis.

type FeatureHandler

type FeatureHandler struct{}

FeatureHandler implements the FeatureAPI interface

func (*FeatureHandler) GetFeature

func (h *FeatureHandler) GetFeature(w http.ResponseWriter, r *http.Request)

GetFeature - Get requested feature

func (*FeatureHandler) ListFeatures

func (h *FeatureHandler) ListFeatures(w http.ResponseWriter, r *http.Request)

ListFeatures - List all features

type Health

type Health struct {
	Status  string   `json:"status,omitempty"`
	Reasons []string `json:"reasons,omitempty"`
}

Health is holding info about health checks

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 NotificationAPI added in v0.12.0

type NotificationAPI interface {
	HandleEventSteam(w http.ResponseWriter, r *http.Request)
}

NotificationAPI defines support for notification via server side events

type NotificationHandler added in v0.12.0

type NotificationHandler struct {
}

A NotificationHandler handles in coming connections as server side event streams streaming notifications per SDK Key (defined in the header)

func NewNotificationHandler added in v0.12.0

func NewNotificationHandler() (nh *NotificationHandler)

NewNotificationHandler is the NotificationHandler factory

func (*NotificationHandler) HandleEventSteam added in v0.12.0

func (nh *NotificationHandler) HandleEventSteam(w http.ResponseWriter, r *http.Request)

HandleEventSteam implements the http.Handler interface. This allows us to wrap HTTP handlers (see auth_handler.go) http://golang.org/pkg/net/http/#Handler

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) GetAPIAccessToken added in v0.12.0

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

GetAPIAccessToken returns a JWT access token for the API service

func (*OAuthHandler) GetAdminAccessToken added in v0.12.0

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

GetAdminAccessToken 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

type UserAPI

type UserAPI interface {
	ListFeatures(w http.ResponseWriter, r *http.Request)
	GetFeature(w http.ResponseWriter, r *http.Request)
	TrackFeatures(w http.ResponseWriter, r *http.Request)
	TrackFeature(w http.ResponseWriter, r *http.Request)

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

	ActivateExperiment(w http.ResponseWriter, r *http.Request)
	GetVariation(w http.ResponseWriter, r *http.Request)
}

UserAPI defines the supported user scoped APIs.

type UserHandler

type UserHandler struct{}

UserHandler implements the UserAPI interface

func (*UserHandler) ActivateExperiment

func (h *UserHandler) ActivateExperiment(w http.ResponseWriter, r *http.Request)

ActivateExperiment - Return the variatoin that a user is bucketed into and track an impression event

func (*UserHandler) GetFeature

func (h *UserHandler) GetFeature(w http.ResponseWriter, r *http.Request)

GetFeature - Return the feature. Note: no impressions recorded for associated feature tests.

func (*UserHandler) GetVariation

func (h *UserHandler) GetVariation(w http.ResponseWriter, r *http.Request)

GetVariation - Return the variation that a user is bucketed into

func (*UserHandler) ListFeatures

func (h *UserHandler) ListFeatures(w http.ResponseWriter, r *http.Request)

ListFeatures - List all feature decisions for a user Note: no impressions recorded for associated feature tests.

func (*UserHandler) TrackEvent

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

TrackEvent - track a given event for the current user

func (*UserHandler) TrackFeature

func (h *UserHandler) TrackFeature(w http.ResponseWriter, r *http.Request)

TrackFeature - Return the feature and record impression if applicable. Tracking impressions is only supported for "Feature Tests" as part of the SDK contract.

func (*UserHandler) TrackFeatures

func (h *UserHandler) TrackFeatures(w http.ResponseWriter, r *http.Request)

TrackFeatures - List all feature decisions for a user. Impression events are recorded for all applicable feature tests.

type UserOverrideAPI added in v0.12.0

type UserOverrideAPI interface {
	SetForcedVariation(w http.ResponseWriter, r *http.Request)
	RemoveForcedVariation(w http.ResponseWriter, r *http.Request)
}

UserOverrideAPI defines supported override functionality

type UserOverrideBody added in v0.12.0

type UserOverrideBody struct {
	VariationKey string `json:"variationKey"`
}

UserOverrideBody defines the overrides to be applied.

type UserOverrideHandler added in v0.12.0

type UserOverrideHandler struct{}

UserOverrideHandler implements the UserAPI interface

func (*UserOverrideHandler) RemoveForcedVariation added in v0.12.0

func (h *UserOverrideHandler) RemoveForcedVariation(w http.ResponseWriter, r *http.Request)

RemoveForcedVariation - Remove a forced variation

func (*UserOverrideHandler) SetForcedVariation added in v0.12.0

func (h *UserOverrideHandler) SetForcedVariation(w http.ResponseWriter, r *http.Request)

SetForcedVariation - set a forced variation

type Variation

type Variation struct {
	ID  string `json:"id"`
	Key string `json:"key"`
}

Variation Model

Jump to

Keyboard shortcuts

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