Skip to content

Commit

Permalink
Merge pull request reactjs#36 from zpao/gogogo
Browse files Browse the repository at this point in the history
Improve Go server
  • Loading branch information
zpao committed Mar 1, 2015
2 parents 18725dd + 45c8e66 commit 3557139
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ func handleComments(w http.ResponseWriter, r *http.Request) {
return
}

w.Header().Set("Content-Type", "application/json")
io.Copy(w, bytes.NewReader(commentData))

case "GET":
w.Header().Set("Content-Type", "application/json")
// stream the contents of the file to the response
io.Copy(w, bytes.NewReader(commentData))

Expand All @@ -81,5 +85,6 @@ func handleComments(w http.ResponseWriter, r *http.Request) {
func main() {
http.HandleFunc("/comments.json", handleComments)
http.Handle("/", http.FileServer(http.Dir("./public")))
log.Println("Server started: http://localhost:3000")
log.Fatal(http.ListenAndServe(":3000", nil))
}

0 comments on commit 3557139

Please sign in to comment.