Clarify comments
This commit is contained in:
parent
f01ac7b716
commit
8b669910e4
14
lemmy.go
14
lemmy.go
@ -38,10 +38,13 @@ func NewWithClient(baseURL string, client *http.Client) (*Client, error) {
|
|||||||
return &Client{baseURL: u, client: client}, nil
|
return &Client{baseURL: u, client: client}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClientLogin logs in to Lemmy by calling the Lemmy endpoint,
|
// ClientLogin logs in to Lemmy by calling the login endpoint, and
|
||||||
// and stores the returned token for use in future requests.
|
// stores the returned token in the Token field for use in future requests.
|
||||||
func (c *Client) ClientLogin(ctx context.Context, l Login) error {
|
//
|
||||||
lr, err := c.Login(ctx, l)
|
// The Token field can be set manually if you'd like to persist the
|
||||||
|
// token somewhere.
|
||||||
|
func (c *Client) ClientLogin(ctx context.Context, data Login) error {
|
||||||
|
lr, err := c.Login(ctx, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -160,7 +163,8 @@ type emptyResponse struct {
|
|||||||
Error Optional[string] `json:"error"`
|
Error Optional[string] `json:"error"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// resError returns an error if the the response contains an error
|
// resError checks if the response contains an error, and if so, returns
|
||||||
|
// a Go error representing it.
|
||||||
func resError(res *http.Response, err Optional[string]) error {
|
func resError(res *http.Response, err Optional[string]) error {
|
||||||
if errstr, ok := err.Value(); ok {
|
if errstr, ok := err.Value(); ok {
|
||||||
return Error{
|
return Error{
|
||||||
|
Loading…
Reference in New Issue
Block a user