Skip to content

Instantly share code, notes, and snippets.

@freeeve
Created March 17, 2016 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freeeve/906b2b9fd90b0f00e26e to your computer and use it in GitHub Desktop.
Save freeeve/906b2b9fd90b0f00e26e to your computer and use it in GitHub Desktop.
package main
import (
"encoding/json"
"fmt"
"net/http"
)
type Person struct {
Name string
Age int
}
func handler(w http.ResponseWriter, r *http.Request) {
eve := Person{Name: "Eve", Age: 33}
buf, err := json.Marshal(eve)
if err != nil {
panic(err)
}
w.Write(buf)
}
func main() {
http.HandleFunc("/", handler)
fmt.Println("hello, we're listening on 5000")
http.ListenAndServe(":5000", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment