Documentation
¶
Overview ¶
Example (BuildURL) ¶
fmt.Println(buildUrlWoErr("http://www.example.com", "foo/bar"))
fmt.Println(buildUrlWoErr("http://www.example.com", "foo/bar?baz=1"))
fmt.Println(buildUrlWoErr("http://www.example.com", "/foo/bar"))
fmt.Println(buildUrlWoErr("http://www.example.com/", "/double-slash"))
Output: http://www.example.com/foo/bar http://www.example.com/foo/bar?baz=1 http://www.example.com/foo/bar http://www.example.com/double-slash
Index ¶
- type Error
- type HttpClient
- func (c *HttpClient) Get(ctx context.Context, path string, handler ResponseHandler, ...) error
- func (c *HttpClient) Post(ctx context.Context, path string, body io.Reader, handler ResponseHandler, ...) error
- func (c *HttpClient) PostForm(ctx context.Context, path string, formValues map[string]string, ...) error
- type RequestOption
- type RequestOptionFunc
- type ResponseHandler
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HttpClient ¶
type HttpClient struct {
// contains filtered or unexported fields
}
func (*HttpClient) Get ¶
func (c *HttpClient) Get(ctx context.Context, path string, handler ResponseHandler, opts ...RequestOption) error
func (*HttpClient) Post ¶
func (c *HttpClient) Post( ctx context.Context, path string, body io.Reader, handler ResponseHandler, opts ...RequestOption, ) error
func (*HttpClient) PostForm ¶
func (c *HttpClient) PostForm( ctx context.Context, path string, formValues map[string]string, handler ResponseHandler, opts ...RequestOption, ) error
type RequestOption ¶
type RequestOptionFunc ¶
func WithAcceptHeader ¶
func WithAcceptHeader(contentType string) RequestOptionFunc
func WithContentType ¶
func WithContentType(contentType string) RequestOptionFunc
func WithHeaders ¶
func WithHeaders(headers map[string]string) RequestOptionFunc
func WithQueryParams ¶
func WithQueryParams(params map[string]string) RequestOptionFunc
type ResponseHandler ¶
Click to show internal directories.
Click to hide internal directories.