Skip to content

Commit

Permalink
changed url2 to url
Browse files Browse the repository at this point in the history
  • Loading branch information
benjoe1126 committed Feb 17, 2025
1 parent 12c9410 commit a9c30a3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions 99-labs/04-immutability/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,18 @@ Your task is to implement this interface. Some help:
// Get returns the value and version stored for the given key, or an error if something goes wrong.
func (c *client) Get(key string) (api.VersionedValue, error) {
//this will append the query parameter formatted to the url
url, _ := url2.Parse(c.url + "/api/get")
q := url.Query()
uri, _ := url.Parse(c.url + "/api/get")
q := uri.Query()
q.Set("id", key)
url.RawQuery = q.Encode()
uri.RawQuery = q.Encode()
...
}
```

The function itself will have to perform the following steps:
- make a HTTP GET call to the HTTP server at the URL `c.url` (`c` is the receiver of the `Get` function of our implementation type `client`) at the API endpoint `/api/get` using the `key` argument as the query id parameter value:
```go
r, err := http.Get(url.String())
r, err := http.Get(uri.String())
```
- return an empty `api.VersionedValue{}` and an error if something goes wrong,
- check if the return status is 200 (`http.StatusOK`) and return an empty `api.VersionedValue{}` and an error if not,
Expand Down

0 comments on commit a9c30a3

Please sign in to comment.