The RESTful API is the most common way applications and servers provide access to their services. This recipe will show you how it can be consumed with the help of a HTTP client from the standard library.
Consuming the RESTful API
How to do it...
- Open the console and create the folder chapter07/recipe09.
- Navigate to the directory.
- Create the rest.go file with the following content:
package main
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"strconv"
"strings"
)
const addr = "localhost:7070"
type City struct {
ID string
...