Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
21 lines (16 sloc) 695 Bytes
package flights // import "go.pedge.io/flights"
import (
"net/http"
"github.com/gorilla/mux"
"go.pedge.io/openflights"
)
// NewHandler returns a new http.Handler.
func NewHandler(openflightsClient openflights.Client, openflightsHandler http.Handler, etcDirPath string) http.Handler {
handler := newHandler(openflightsClient, etcDirPath)
router := mux.NewRouter()
router.PathPrefix("/static/").Methods("GET").Handler(http.FileServer(http.Dir(etcDirPath)))
router.Path("/").Methods("GET").HandlerFunc(handler.indexGet)
router.Path("/miles").Methods("GET").HandlerFunc(handler.milesGet)
router.PathPrefix("/api/").Handler(http.StripPrefix("/api", openflightsHandler))
return router
}