added a json handler

This commit is contained in:
sm
2013-05-08 23:41:59 -07:00
parent a8ceec3d6b
commit 97f18f1df2
3 changed files with 10 additions and 3 deletions
+7
View File
@@ -14,6 +14,13 @@ type prob struct {
Last int
}
type JsonHandler func(http.ResponseWriter, *http.Request)
func (h JsonHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "application/json")
h(w, req)
}
func problem(w http.ResponseWriter, req *http.Request) {
operation := "+"
if r := rand.Intn(2); r == 0 {