Last active
November 17, 2018 15:45
-
-
Save unders/c8ec1892b6d6a23f5544acc0014b66cc to your computer and use it in GitHub Desktop.
Revisions
-
unders revised this gist
Nov 17, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ type server struct { } func (s *server) product() http.HandlerFunc { type getRequest struct { Name string } -
unders revised this gist
Nov 17, 2018 . 1 changed file with 15 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -14,30 +14,37 @@ func productHandler(w http.ResponseWriter, r *http.Request) { ``` type server struct { container *someContainer router *someRouter } func (s *server) productIndex() http.HandlerFunc { type getRequest struct { Name string } type getResponse struct { Greeting string `json:"greeting"` } get := func(r *http.Request) () { } GET /products POST /products GET /products/10 PUT /products/10 return func(w http.ResponseWriter, r *http.Request) { key := r.URL.Path[len("/products/"):] switch r.Method { case "GET": data, err := parseGet(r) s.container.Get case "POST": // Fo POST stuff default: http.Error(w, s.template.NotAllowed(), 405) } } } -
unders revised this gist
Nov 17, 2018 . 1 changed file with 10 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,15 +13,24 @@ func productHandler(w http.ResponseWriter, r *http.Request) { ``` ``` type server struct { db *someDatabase router *someRouter } func (s *server) handleSomething() http.HandlerFunc { type request struct { Name string } type response struct { Greeting string `json:"greeting"` } return func(w http.ResponseWriter, r *http.Request) { key := r.URL.Path[len("/products/"):] switch r.Method { case "GET": // do GET stuff -
unders revised this gist
Nov 17, 2018 . 1 changed file with 25 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ ``` func productHandler(w http.ResponseWriter, r *http.Request) { key := r.URL.Path[len("/products/"):] switch r.Method { @@ -9,4 +9,27 @@ func productHandler(w http.ResponseWriter, r *http.Request) { default: http.Error(w, "Method Not Allowed", 405) } } ``` ``` func (s *server) handleSomething() http.HandlerFunc { type request struct { Name string } type response struct { Greeting string `json:"greeting"` } return func(w http.ResponseWriter, r *http.Request) { key := r.URL.Path[len("/products/"):] switch r.Method { case "GET": // do GET stuff case "POST": // Fo POST stuff default: http.Error(w, "Method Not Allowed", 405) } } } ``` -
unders created this gist
Nov 17, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ ```` func productHandler(w http.ResponseWriter, r *http.Request) { key := r.URL.Path[len("/products/"):] switch r.Method { case "GET": // do GET stuff case "POST": // Fo POST stuff default: http.Error(w, "Method Not Allowed", 405) } }