add variable and method comments

This commit is contained in:
Mike Mason
2023-07-17 19:02:55 +00:00
parent 2681b3d064
commit bc87fa7726
35 changed files with 157 additions and 16 deletions

View File

@@ -21,6 +21,7 @@ var defaultHTTPClient = &http.Client{
Timeout: 5 * time.Second,
}
// Client is the permissions client.
type Client struct {
logger *zap.SugaredLogger
@@ -32,6 +33,8 @@ type Client struct {
allowURL *url.URL
}
// Do executes the provided request.
// If the out value is provided, the response will attempt to be json decoded.
func (c *Client) Do(req *http.Request, out any) (*http.Response, error) {
if c.token != "" {
req.Header.Set(echo.HeaderAuthorization, "Bearer "+c.token)
@@ -55,6 +58,7 @@ func (c *Client) Do(req *http.Request, out any) (*http.Response, error) {
return resp, nil
}
// DoRequest creates a new request from the provided parameters and executes the request.
func (c *Client) DoRequest(ctx context.Context, method, path string, body io.Reader, out any) (*http.Response, error) {
path = strings.TrimPrefix(path, c.baseURL.Path)