Documentation
¶
Overview ¶
Package http provides HTTP client functionality for making requests. Designed as a bridge for Lua functions to perform HTTP operations.
Index ¶
- type Client
- type DefaultClient
- func (c *DefaultClient) Delete(req Request) (Response, error)
- func (c *DefaultClient) Get(req Request) (Response, error)
- func (c *DefaultClient) Patch(req Request) (Response, error)
- func (c *DefaultClient) Post(req Request) (Response, error)
- func (c *DefaultClient) Put(req Request) (Response, error)
- type Error
- type FakeClient
- func (f *FakeClient) Delete(req Request) (Response, error)
- func (f *FakeClient) Get(req Request) (Response, error)
- func (f *FakeClient) Patch(req Request) (Response, error)
- func (f *FakeClient) Post(req Request) (Response, error)
- func (f *FakeClient) Put(req Request) (Response, error)
- func (f *FakeClient) SetError(method, url string, err error)
- func (f *FakeClient) SetResponse(method, url string, response Response)
- type Headers
- type Query
- type Request
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
Get(req Request) (Response, error)
Post(req Request) (Response, error)
Put(req Request) (Response, error)
Patch(req Request) (Response, error)
Delete(req Request) (Response, error)
}
Client is an interface for making HTTP requests
type DefaultClient ¶
type DefaultClient struct {
// contains filtered or unexported fields
}
DefaultClient is the default implementation of Client
func NewDefaultClient ¶
func NewDefaultClient() *DefaultClient
NewDefaultClient creates a new default HTTP client with timeout and connection pooling
func (*DefaultClient) Delete ¶
func (c *DefaultClient) Delete(req Request) (Response, error)
Delete performs an HTTP DELETE request
func (*DefaultClient) Get ¶
func (c *DefaultClient) Get(req Request) (Response, error)
Get performs an HTTP GET request
func (*DefaultClient) Patch ¶
func (c *DefaultClient) Patch(req Request) (Response, error)
Patch performs an HTTP PATCH request
type FakeClient ¶
type FakeClient struct {
// Responses maps method+URL to a Response
Responses map[string]Response
// Errors maps method+URL to an error
Errors map[string]error
// Requests stores all requests made (for verification)
Requests []Request
}
FakeClient is a stub implementation of Client for testing
func NewFakeClient ¶
func NewFakeClient() *FakeClient
NewFakeClient creates a new fake HTTP client for testing
func (*FakeClient) Delete ¶
func (f *FakeClient) Delete(req Request) (Response, error)
Delete performs a fake HTTP DELETE request
func (*FakeClient) Get ¶
func (f *FakeClient) Get(req Request) (Response, error)
Get performs a fake HTTP GET request
func (*FakeClient) Patch ¶
func (f *FakeClient) Patch(req Request) (Response, error)
Patch performs a fake HTTP PATCH request
func (*FakeClient) Post ¶
func (f *FakeClient) Post(req Request) (Response, error)
Post performs a fake HTTP POST request
func (*FakeClient) Put ¶
func (f *FakeClient) Put(req Request) (Response, error)
Put performs a fake HTTP PUT request
func (*FakeClient) SetError ¶
func (f *FakeClient) SetError(method, url string, err error)
SetError configures a fake error for a given method and URL
func (*FakeClient) SetResponse ¶
func (f *FakeClient) SetResponse(method, url string, response Response)
SetResponse configures a fake response for a given method and URL