Skip to content

Instantly share code, notes, and snippets.

@elliotforbes
Created July 3, 2018 14:10
Show Gist options
  • Save elliotforbes/47339b14ae63050f4da93357b09f83a1 to your computer and use it in GitHub Desktop.
Save elliotforbes/47339b14ae63050f4da93357b09f83a1 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
)
// Article - Our struct for all articles
type Article struct {
Id int `json:"Id"`
Title string `json:"Title"`
Desc string `json:"desc"`
Content string `json:"content"`
}
type Articles []Article
func rootEndpoint(w http.ResponseWriter, r *http.Request) {
fmt.Println("Endpoint Hit: root")
fmt.Fprintf(w, "Hello World!")
}
func handleRequests() {
myRouter := mux.NewRouter().StrictSlash(true)
myRouter.HandleFunc("/", rootEndpoint)
log.Fatal(http.ListenAndServe(":9000", myRouter))
}
func main() {
handleRequests()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment