Created
February 9, 2016 21:15
-
-
Save niklas88/cf1cb3e407ccbf287f5c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"github.com/gorilla/handlers" | |
"github.com/gorilla/mux" | |
"net/http" | |
"os" | |
) | |
var listenInterface string | |
func init() { | |
flag.StringVar(&listenInterface, "interface", ":8080", "The interface to listen on, including the port") | |
} | |
func main() { | |
flag.Parse() | |
r := mux.NewRouter() | |
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |
w.Write([]byte("This is a catch-all route")) | |
}) | |
loggedRouter := handlers.LoggingHandler(os.Stdout, r) | |
http.ListenAndServe(listenInterface, loggedRouter) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment