Created
July 3, 2018 14:10
-
-
Save elliotforbes/47339b14ae63050f4da93357b09f83a1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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" | |
) | |
// 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