Skip to content

Instantly share code, notes, and snippets.

@jiripospisil
Created August 19, 2013 09:12
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 jiripospisil/6267179 to your computer and use it in GitHub Desktop.
Save jiripospisil/6267179 to your computer and use it in GitHub Desktop.
package main
import (
"encoding/json"
"log"
"net/http"
"runtime"
)
type Article struct {
Name, Body string
}
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
article := &Article{"A Royal Baby", "A slow news week"}
e := json.NewEncoder(w)
e.Encode(article)
})
log.Fatal(http.ListenAndServe(":8080", nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment