Created
August 19, 2013 09:12
-
-
Save jiripospisil/6267179 to your computer and use it in GitHub Desktop.
This file contains 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 ( | |
"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