Created
July 31, 2015 14:11
-
-
Save marciol/48d541edfa9ce9bbef4e 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
// Example of how to use stdlib in go, leveraging the simplicity of solutions without dependencies | |
// based on https://www.youtube.com/watch?v=yi5A3cK1LNA&feature=youtu.be&t=11m45s | |
func productHandler(w http.ResponseWriter, r *http.Request) { | |
key := r.URL.PATH[len("/products/"):] | |
switch r.Method { | |
case "GET": | |
// do get stuff | |
case "POST": | |
// do post stuff | |
default: | |
http.Error(w, "Method not allowed", 405) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment