diff options
| author | Shulhan <m.shulhan@gmail.com> | 2020-05-16 19:52:33 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2020-05-16 19:52:33 +0700 |
| commit | 56c992b6d3597e37e5dbfd7bbd63b7f1311c8b8e (patch) | |
| tree | 1fb660ab438c39d5ea9c99b2beb60126df3a77b7 /lib/http | |
| parent | 04a7f25930191e76928f575d796d2972811a4fac (diff) | |
| download | pakakeh.go-56c992b6d3597e37e5dbfd7bbd63b7f1311c8b8e.tar.xz | |
all: fix and suppress linter warnings
Diffstat (limited to 'lib/http')
| -rw-r--r-- | lib/http/client.go | 12 | ||||
| -rw-r--r-- | lib/http/responsetype.go | 2 | ||||
| -rw-r--r-- | lib/http/serveroptions.go | 18 |
3 files changed, 16 insertions, 16 deletions
diff --git a/lib/http/client.go b/lib/http/client.go index 67342fd9..661e57a8 100644 --- a/lib/http/client.go +++ b/lib/http/client.go @@ -75,7 +75,7 @@ func NewClient(serverURL string, headers http.Header, insecure bool) (client *Cl MaxIdleConns: 100, IdleConnTimeout: 90 * time.Second, TLSClientConfig: &tls.Config{ - InsecureSkipVerify: insecure, + InsecureSkipVerify: insecure, //nolint: gosec }, TLSHandshakeTimeout: 10 * time.Second, ExpectContinueTimeout: 1 * time.Second, @@ -138,7 +138,7 @@ func (client *Client) PostForm(path string, params url.Values) ( httpReq, err := http.NewRequest(http.MethodPost, url, body) if err != nil { - return nil, fmt.Errorf("Post: %w", err) + return nil, fmt.Errorf("client.PostForm: %w", err) } client.setHeaders(httpReq) @@ -146,17 +146,17 @@ func (client *Client) PostForm(path string, params url.Values) ( httpRes, err := client.Client.Do(httpReq) if err != nil { - return nil, fmt.Errorf("Post: %w", err) + return nil, fmt.Errorf("client.PostForm: %w", err) } resBody, err = ioutil.ReadAll(httpRes.Body) if err != nil { - return nil, fmt.Errorf("Post: %w", err) + return nil, fmt.Errorf("client.PostForm: %w", err) } err = httpRes.Body.Close() if err != nil { - return nil, fmt.Errorf("Post: %w", err) + return nil, fmt.Errorf("client.PostForm: %w", err) } return client.uncompress(httpRes, resBody) @@ -180,7 +180,7 @@ func (client *Client) PostFormData(path string, params map[string][]byte) ( httpReq, err := http.NewRequest(http.MethodPost, url, body) if err != nil { - return nil, fmt.Errorf("Post: %w", err) + return nil, fmt.Errorf("http: PostFormData: %w", err) } client.setHeaders(httpReq) diff --git a/lib/http/responsetype.go b/lib/http/responsetype.go index 3cb4254d..ecd11d6f 100644 --- a/lib/http/responsetype.go +++ b/lib/http/responsetype.go @@ -4,7 +4,7 @@ package http -// ResponseType define type for HTTP response +// ResponseType define type for HTTP response. type ResponseType int // List of valid response type. diff --git a/lib/http/serveroptions.go b/lib/http/serveroptions.go index 71278857..13cd6ac5 100644 --- a/lib/http/serveroptions.go +++ b/lib/http/serveroptions.go @@ -37,28 +37,23 @@ type ServerOptions struct { // This field is optional. Excludes []string - // CORSAllowCredentials indicates whether or not the actual request - // can be made using credentials. - CORSAllowCredentials bool - // CORSAllowOrigins contains global list of cross-site Origin that are // allowed during preflight requests by the OPTIONS method. // The list is case-sensitive. // To allow all Origin, one must add "*" string to the list. - CORSAllowOrigins []string - corsAllowOriginsAll bool // flag to indicate wildcards on list. + CORSAllowOrigins []string // CORSAllowHeaders contains global list of allowed headers during // preflight requests by the OPTIONS method. // The list is case-insensitive. // To allow all headers, one must add "*" string to the list. - CORSAllowHeaders []string - corsAllowHeadersAll bool // flag to indicate wildcards on list. + CORSAllowHeaders []string // CORSExposeHeaders contains list of allowed headers. // This list will be send when browser request OPTIONS without // request-method. CORSExposeHeaders []string + exposeHeaders string // CORSMaxAge gives the value in seconds for how long the response to // the preflight request can be cached for without sending another @@ -66,11 +61,16 @@ type ServerOptions struct { CORSMaxAge int corsMaxAge string + // CORSAllowCredentials indicates whether or not the actual request + // can be made using credentials. + CORSAllowCredentials bool + // Development if its true, the Root file system is served by reading // the content directly instead of using memory file system. Development bool - exposeHeaders string + corsAllowHeadersAll bool // flag to indicate wildcards on list. + corsAllowOriginsAll bool // flag to indicate wildcards on list. } func (opts *ServerOptions) init() { |
