Skip to content
Snippets Groups Projects
Commit d31a584a authored by jotangen's avatar jotangen
Browse files

added default handler /

parent ec62bb0a
Branches
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@ package main
import (
"fmt"
"html"
"log"
"net/http"
"os"
......@@ -33,6 +34,7 @@ func urlSplitForCountry(a string)(string, string){
func defaultHandler(w http.ResponseWriter, r *http.Request){
//code to be added
fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
}
func viewHandler(w http.ResponseWriter, r *http.Request) {
......@@ -82,7 +84,7 @@ var Start time.Time
// Main function
func main() {
port := os.Getenv("PORT")
if port == "" {
//log.fatal formatting output and exits
log.Fatal("$PORT must be set")
......@@ -94,7 +96,7 @@ func main() {
// under the path / remember to end with trailing /
// Add code to this function
http.HandleFunc("/conservation/v1/", defaultHandler)
http.HandleFunc("/", defaultHandler)
http.HandleFunc("/conservation/v1/country/name/", viewHandler)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment