Documentation ¶
Index ¶
Examples ¶
Constants ¶
const DefaultName = "default"
DefaultName is the name of the default version The version with this name will take up the rest of the probability if any remain when adding all probabilities together
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger interface {
Printf(string, ...interface{})
}
Logger is the logger interface used with revaboxy
type Revaboxy ¶
type Revaboxy struct {
// contains filtered or unexported fields
}
Revaboxy creates an A/B test between different urls. It does also save which test i run on the client through cookies and serve the same version on subsequent requests The revaboxy handler should be created with New
func New ¶
New creates a revaboxy client. Versions required but, any number of additional settings may be provided
Example ¶
package main import ( "log" "net/http" "net/url" "github.com/lindell/revaboxy/pkg/revaboxy" ) func main() { defaultURL, _ := url.Parse("http://defaulturl") greenBackgroundURL, _ := url.Parse("http://greenbackgroundurl") rp, err := revaboxy.New([]revaboxy.Version{ { revaboxy.DefaultName, defaultURL, 0.7, }, { "green-background", greenBackgroundURL, 0.3, }, }) if err != nil { log.Fatal(err) } log.Fatal(http.ListenAndServe(":8080", rp)) }
Output:
type Setting ¶
type Setting func(s *settings)
Setting changes the revaboxy settings
func WithCookieExpiry ¶
WithCookieExpiry sets the expiry time of the client cookie, default is 3 days
func WithCookieName ¶
WithCookieName sets the name of the cookie that where the selected version is stored If the value is not set with this setting, it will default to the default, "revaboxy-name"
func WithHeaderName ¶
WithHeaderName sets the name of the header that is set for the downsteam service to use The header will contain the name of the version used If the value is not set with this setting, it will default to the default, "revaboxy-name"
func WithTransport ¶
func WithTransport(rt http.RoundTripper) Setting
WithTransport sets the http transport to be used