Documentation ¶
Overview ¶
Package handlers //
Package handlers //
Package handlers //
Package handlers //
Package handlers //
Package handlers //
Package handlers //
Index ¶
- func ParseRequestBody(r *http.Request, v interface{}) error
- func RenderError(err error, status int, w http.ResponseWriter, r *http.Request)
- type Admin
- type DatafileUpdateData
- type ErrorResponse
- type Experiment
- type ExperimentAPI
- type ExperimentHandler
- type Feature
- type FeatureAPI
- type FeatureHandler
- type Health
- type JSON
- type OptlyMessage
- type OptlyWebhookHandler
- type UserAPI
- type UserHandler
- func (h *UserHandler) ActivateExperiment(w http.ResponseWriter, r *http.Request)
- func (h *UserHandler) GetFeature(w http.ResponseWriter, r *http.Request)
- func (h *UserHandler) GetVariation(w http.ResponseWriter, r *http.Request)
- func (h *UserHandler) ListFeatures(w http.ResponseWriter, r *http.Request)
- func (h *UserHandler) RemoveForcedVariation(w http.ResponseWriter, r *http.Request)
- func (h *UserHandler) SetForcedVariation(w http.ResponseWriter, r *http.Request)
- func (h *UserHandler) TrackEvent(w http.ResponseWriter, r *http.Request)
- func (h *UserHandler) TrackFeature(w http.ResponseWriter, r *http.Request)
- func (h *UserHandler) TrackFeatures(w http.ResponseWriter, r *http.Request)
- type Variation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseRequestBody ¶
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 ¶
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 (Admin) AppInfo ¶
func (a Admin) AppInfo(w http.ResponseWriter, r *http.Request)
AppInfo returns custom app-info
func (Admin) AppInfoHeader ¶
AppInfoHeader adds custom app-info to the response header
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 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 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.