Skip to content

Instantly share code, notes, and snippets.

@Duncanian
Created May 30, 2019 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Duncanian/4bfd3526f7ec6b9b7d822581a05cebd9 to your computer and use it in GitHub Desktop.
Save Duncanian/4bfd3526f7ec6b9b7d822581a05cebd9 to your computer and use it in GitHub Desktop.
This the code for the go-rest-api (The home endpoint)
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