Select Git revision
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
main.go 769 B
package main
import (
"assignment-1/handler"
"github.com/gorilla/mux"
"log"
"net/http"
"os"
)
func main() {
r := mux.NewRouter()
port := os.Getenv("PORT")
if port == "" {
port = "5000"
}
c := r.PathPrefix("/conservation/v1").Methods("GET").Subrouter()
// two handlerpaths makes sure that the caller does not HAVE to specify limit
c.Path("/country/{country_identifier:[a-zA-Z][a-zA-Z]}").
Queries("limit", "{limit}").
HandlerFunc(handler.Chandler).
Name("Handel")
c.Path("/country/{country_identifier:[a-zA-Z][a-zA-Z]}").
HandlerFunc(handler.Chandler)
c.Path("/species/{speciesKey}").
HandlerFunc(handler.Shandler)
c.Path("/diag/").
HandlerFunc(handler.Dhandler)
http.Handle("/", r)
log.Fatal(http.ListenAndServe(":"+port, nil))
}