项目作者: ClippyForever

项目描述 :
Go Go Go
高级语言: Go
项目地址: git://github.com/ClippyForever/websoc-api-go.git
创建时间: 2019-05-29T04:30:48Z
项目社区:https://github.com/ClippyForever/websoc-api-go

开源协议:

下载


Welcome to My Go!

Example

Go Here Go, .

List of parameters:

  • department
  • term
  • GE
  • courseNum
  • courseCodes
  • instructorName
  • units
  • endTime
  • startTime
  • fullCourses
  • building

Full Link: https://971k1pm7de.execute-api.us-west-1.amazonaws.com/dev/websoc?department=COMPSCI&term=2019%20Fall&GE=ANY&courseNum=&courseCodes=&instructorName=&units=&endTime=&startTime=&fullCourses=ANY&building=

Usage

  1. func getResult(w http.ResponseWriter, r *http.Request) {
  2. result := MakeRequest()
  3. w.Header().Set("Content-Type", "application/json")
  4. json.NewEncoder(w).Encode(result.Schools.Schools)
  5. }
  6. func main() {
  7. r := mux.NewRouter()
  8. r.HandleFunc("/api/", getResult).Methods("GET")
  9. //run on local
  10. log.Fatal(http.ListenAndServe(":8000", r))
  11. fmt.Println("Hello")
  12. }

To Run On Local

Get Mux router library first
Type in and enter “go get -u github.com/gorilla/mux” in the terminal

Remember to import Mux library

  1. import (
  2. "github.com/gorilla/mux"
  3. )

Two options to run:

  1. Type in and enter “go run main.go” to run without compiling the program first.
  2. Type in and enter “go build” then “./nameOftheProgram” to run with compiling.