Skip to content

Instantly share code, notes, and snippets.

@a-h
Created August 30, 2016 16:30
Show Gist options
  • Select an option

  • Save a-h/af4ade34b78e8ca4fd76224defee9ffe to your computer and use it in GitHub Desktop.

Select an option

Save a-h/af4ade34b78e8ca4fd76224defee9ffe to your computer and use it in GitHub Desktop.
Version Web Server
package main
import (
"io"
"log"
"net/http"
"github.com/gorilla/mux"
)
func main() {
r := mux.NewRouter()
r.HandleFunc("/", hello)
r.HandleFunc("/version", version)
log.Fatal(http.ListenAndServe(":8080", r))
}
func hello(w http.ResponseWriter, req *http.Request) {
io.WriteString(w, "Hello!")
}
func version(w http.ResponseWriter, req *http.Request) {
io.WriteString(w, "0.0.1")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment