O'Reilly logo

Isomorphic Go by Kamesh Balasubramanian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The gopher team Rest API endpoint

The /restapi/get-gopher-team route is handled by the GetGopherTeamEndpoint function defined in the gopherteam.go source file found in the endpoints folder:

func GetGopherTeamEndpoint(env *common.Env) http.Handler {  return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {    gophers := env.DB.GetGopherTeam()    w.Header().Set("Content-Type", "application/json")    json.NewEncoder(w).Encode(gophers)  })}

We will declare and initialize the gophers variable to the value returned from calling the GetGopherTeam method of the Redis datastore object, env.DB. We will then set a header to indicate that the server will be sending a JSON response. Finally, we will use a JSON encoder to encode the slice of gophers ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required