Created
May 30, 2019 17:59
-
-
Save Duncanian/4bfd3526f7ec6b9b7d822581a05cebd9 to your computer and use it in GitHub Desktop.
This the code for the go-rest-api (The home endpoint)
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
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
"github.com/gorilla/mux" | |
) | |
func homeLink(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprintf(w, "Welcome home!") | |
} | |
func main() { | |
router := mux.NewRouter().StrictSlash(true) | |
router.HandleFunc("/", homeLink) | |
log.Fatal(http.ListenAndServe(":8080", router)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment