Skip to content

Instantly share code, notes, and snippets.

@farhany
Created April 21, 2019 16:30
Show Gist options
  • Save farhany/a5eb29da6befab7ceda30e302988b5a8 to your computer and use it in GitHub Desktop.
Save farhany/a5eb29da6befab7ceda30e302988b5a8 to your computer and use it in GitHub Desktop.
Minimum Gorilla Web Snippet
package main
import (
"net/http"
"github.com/gorilla/mux"
)
func homeHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello!"))
}
func main() {
router := mux.NewRouter().StrictSlash(false)
router.Path("/").HandlerFunc(homeHandler).Methods("GET")
http.ListenAndServe(":8080", router)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment