forked from untoldone/bloomapi
/
bloomapi.go
41 lines (34 loc) · 1.3 KB
/
bloomapi.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package bloomapi
import (
"fmt"
"github.com/gorilla/mux"
"github.com/codegangsta/negroni"
"github.com/gorilla/context"
"github.com/spf13/viper"
"github.com/gocodo/bloomdb"
)
var bdb *bloomdb.BloomDatabase
func Server() {
fmt.Println("Running Server")
bdb = bloomdb.CreateDB()
router := mux.NewRouter()
router.HandleFunc("/api/search", SearchHandler).Methods("GET")
router.HandleFunc("/api/npis/{npi:[0-9]+}", NpiHandler).Methods("GET")
router.HandleFunc("/api/sources", SourcesHandler).Methods("GET")
router.HandleFunc("/api/search/{source}", SearchSourceHandler).Methods("GET")
router.HandleFunc("/api/sources/{source}/{id}", ItemHandler).Methods("GET")
/*runtime.SetBlockProfileRate(1)
dr := router.PathPrefix("/debug/pprof").Subrouter()
dr.HandleFunc("/", pprof.Index)
dr.HandleFunc("/cmdline", pprof.Cmdline)
dr.HandleFunc("/profile", pprof.Profile)
dr.HandleFunc("/symbol", pprof.Symbol)
dr.HandleFunc("/block", pprof.Handler("block").ServeHTTP)
dr.HandleFunc("/heap", pprof.Handler("heap").ServeHTTP)
dr.HandleFunc("/goroutine", pprof.Handler("goroutine").ServeHTTP)
dr.HandleFunc("/threadcreate", pprof.Handler("threadcreate").ServeHTTP)*/
n := negroni.Classic()
n.Use(negroni.HandlerFunc(preJSONP))
n.UseHandler(context.ClearHandler(router))
n.Run(":" + viper.GetString("bloomapiPort"))
}