Go Go Go
Go Here Go, .
func getResult(w http.ResponseWriter, r *http.Request) {
result := MakeRequest()
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(result.Schools.Schools)
}
func main() {
r := mux.NewRouter()
r.HandleFunc("/api/", getResult).Methods("GET")
//run on local
log.Fatal(http.ListenAndServe(":8000", r))
fmt.Println("Hello")
}
Get Mux router library first
Type in and enter “go get -u github.com/gorilla/mux” in the terminal
Remember to import Mux library
import (
"github.com/gorilla/mux"
)
Two options to run: