handlers

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

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 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.

Types

type Admin

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

Admin is holding info to pass to admin handlers

func NewAdmin

func NewAdmin(version, author, appName string) *Admin

NewAdmin initializes admin

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 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]string `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 JSON

type JSON map[string]interface{}

JSON is a map alias, just for convenience

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 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)
	SetForcedVariation(w http.ResponseWriter, r *http.Request)
	RemoveForcedVariation(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) RemoveForcedVariation

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

RemoveForcedVariation - Remove a forced variation

func (*UserHandler) SetForcedVariation

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

SetForcedVariation - set a forced variation

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