Created
August 30, 2016 16:30
-
-
Save a-h/af4ade34b78e8ca4fd76224defee9ffe to your computer and use it in GitHub Desktop.
Version Web Server
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 ( | |
| "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