Skip to content

Instantly share code, notes, and snippets.

@niklas88
Created February 9, 2016 21:15
Show Gist options
  • Save niklas88/cf1cb3e407ccbf287f5c to your computer and use it in GitHub Desktop.
Save niklas88/cf1cb3e407ccbf287f5c to your computer and use it in GitHub Desktop.
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