diff options
| author | Shulhan <ms@kilabit.info> | 2024-04-06 17:44:13 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2024-04-06 17:44:13 +0700 |
| commit | 3245b00f0246f7f2f0afd8635cfd3ff9bf2cf584 (patch) | |
| tree | 286817224a5d72569e4db335578b3549f566deda /api_client.go | |
| parent | 6c7bfd42bc1128f5969e9e40b23d6b828601f7cb (diff) | |
| download | kamusku-3245b00f0246f7f2f0afd8635cfd3ff9bf2cf584.tar.xz | |
all: replace "share" module with "pakakeh.go"
The "share" module has been moved to new forge, SourceHut, with new name
"pakakeh.go".
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 |
