Documentation
¶
Overview ¶
Package kbhttp provides a simple HTTP client for testing with Katabole.
For a canonical usage example see https://github.com/katabole/kbexample/tree/main/actions
Example:
client := kbhttp.NewClient(kbhttp.ClientConfig{BaseURL: "http://localhost:3000/"})
var user models.User
if err := f.Client.GetJSON("/users/12345", &user); err != nil {
t.Fatalf("failed to get user: %v", err)
}
user.Name = "Tom"
if err := f.Client.PutJSON("/users/12345", user, nil); err != nil {
t.Fatalf("failed to update user: %v", err)
}
Index ¶
- type Client
- func (c *Client) DeleteJSON(urlPath string, target any) error
- func (c *Client) DeletePage(urlPath string) (string, error)
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) DoJSON(req *http.Request, target any) error
- func (c *Client) DoPage(req *http.Request) (string, error)
- func (c *Client) GetJSON(urlPath string, target any) error
- func (c *Client) GetPage(urlPath string) (string, error)
- func (c *Client) PostJSON(urlPath string, input any, target any) error
- func (c *Client) PostPage(urlPath string, input url.Values) (string, error)
- func (c *Client) PutJSON(urlPath string, input any, target any) error
- func (c *Client) PutPage(urlPath string, input url.Values) (string, error)
- type ClientConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
func NewClient ¶
func NewClient(config ClientConfig) *Client
type ClientConfig ¶
Click to show internal directories.
Click to hide internal directories.