Example #1
0
func main() {
	es, err := bandit.NewExperiments(bandit.NewOpener(*apiExperiments))
	if err != nil {
		log.Fatalf("could not initialize experiments: %s", err.Error())
	}

	m := pat.New()
	m.Get("/experiments/:name", http.HandlerFunc(bhttp.SelectionHandler(es, *apiPinTTL)))
	http.Handle("/", m)

	// serve
	log.Fatal(http.ListenAndServe(*apiBind, nil))
}
Example #2
0
func main() {
	e, err := bandit.NewExperiments(bandit.NewFileOpener(*exExperiments))
	if err != nil {
		log.Fatalf("could not construct experiments: %s", err.Error())
	}

	// routes
	mux := pat.New()
	mux.Get("/es/:name", bhttp.SelectionHandler(e, *exPinTTL))
	mux.Get("/widget", http.HandlerFunc(widget))
	mux.Get("/feedback", bhttp.LogRewardHandler(e))
	mux.Get("/", http.HandlerFunc(index))
	http.Handle("/", mux)

	// serve
	log.Fatal(http.ListenAndServe(*exBind, nil))
}