Commit 5358142a authored by Mike Shoup's avatar Mike Shoup

Add golang app

parent f79e471b
package main
import (
"encoding/json"
"log"
"net/http"
"github.com/gorilla/mux"
)
type Message struct {
Hello string `json:"hello"`
}
func GetHelloHandler(w http.ResponseWriter, r *http.Request) {
m := &Message{Hello: "world"}
j, _ := json.Marshal(m)
w.Header().Set("Content-Type", "application/json")
w.Write(j)
}
func main() {
r := mux.NewRouter()
r.HandleFunc("/hello", GetHelloHandler).Methods("GET")
http.Handle("/", r)
log.Fatal(http.ListenAndServe(":8000", nil))
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment