diff options
Diffstat (limited to 'api_client.go')
| -rw-r--r-- | api_client.go | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/api_client.go b/api_client.go index 10e487a..95b1a63 100644 --- a/api_client.go +++ b/api_client.go @@ -7,7 +7,7 @@ package kamusd import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "strings" @@ -15,18 +15,14 @@ import ( "git.sr.ht/~shulhan/kamusku" ) -// // apiClient is client that connect to cached server API. -// type apiClient struct { url string conn *http.Client } -// // newAPIClient create a new client for server API. // If url is empty it will use default server API. -// func newAPIClient(url string) (client *apiClient) { if len(url) == 0 { url = defServerAPI @@ -42,12 +38,8 @@ func newAPIClient(url string) (client *apiClient) { return client } -// // Lookup the definition of words through server API. -// -func (client *apiClient) Lookup(words []string) ( - res kamusku.LookupResponse, err error, -) { +func (client *apiClient) Lookup(words []string) (res kamusku.LookupResponse, err error) { if len(words) == 0 { return nil, nil } @@ -67,7 +59,9 @@ func (client *apiClient) Lookup(words []string) ( return nil, fmt.Errorf("Lookup: %w", err) } - resBody, err := ioutil.ReadAll(httpRes.Body) + var resBody []byte + + resBody, err = io.ReadAll(httpRes.Body) if err != nil { return nil, fmt.Errorf("Lookup: %w", err) } @@ -86,9 +80,7 @@ func (client *apiClient) Lookup(words []string) ( return res, nil } -// // ListRootWords list all of the root words in dictionary. -// func (client *apiClient) ListRootWords() (res kamusku.Words, err error) { //TODO: return cached list. return res, nil |
