Documentation ¶
Index ¶
- Variables
- func AddHeaders(q map[string]string) func(*http.Request)
- func AddQuery(q url.Values) func(*http.Request)
- func BeforeRequest(r *http.Request)
- func Call(ctx context.Context, method, url string, body io.Reader, ...) (*http.Response, error)
- func CallJSON(ctx context.Context, method, url string, body interface{}, ...) (*http.Response, error)
- func Data(o interface{}) func(*http.Response, error) error
- func Delete(ctx context.Context, url string, body io.Reader, fn ...func(*http.Request)) (*http.Response, error)
- func Do(r *http.Request) (*http.Response, error)
- func Error(res *http.Response) error
- func Get(ctx context.Context, url string, body io.Reader, fn ...func(*http.Request)) (*http.Response, error)
- func IgnoreNotFound(err error) error
- func IsNotFound(err error) bool
- func IsTODO(err error) bool
- func JSON(res *http.Response, o interface{}) error
- func Join(parts ...string) string
- func JoinURL(base string, parts ...string) string
- func LError(ctx context.Context, err error, msg string, kv ...interface{})
- func LInfo(ctx context.Context, msg string, kv ...interface{})
- func Post(ctx context.Context, url string, body io.Reader, fn ...func(*http.Request)) (*http.Response, error)
- func PostJSON(ctx context.Context, url string, body interface{}, fn ...func(*http.Request)) (*http.Response, error)
- func PutJSON(ctx context.Context, url string, body interface{}, fn ...func(*http.Request)) (*http.Response, error)
- func Request(ctx context.Context, method, url string, body io.Reader) (*http.Request, error)
- func Result(res *http.Response, err error) (*model.Result, error)
- func RunRequestKase(t *testing.T, e environmet.Env, fn func(context.Context) error, kase ...Kase)
- func SetContext(ctx context.Context, rctx Context) context.Context
- func SetHeaders(q map[string]string) func(*http.Request)
- type Context
- type Kase
- type RequestKase
- type ResponseKase
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.New("Resource not found") ErrFailed = errors.New("Failed api call") )
ErrNotFound is returned when an api call returns 404
View Source
var ErrTODO = errors.New("TODO: This feature is not implemented yet")
ErrTODO is returned when a feature is not yet implemented
Functions ¶
func BeforeRequest ¶
func IgnoreNotFound ¶
IgnoreNotFound returns nil if err is ErrNotFound
func RunRequestKase ¶
RunRequestKase this helps check if we are sending a correct request. This assumes fn will only perform a single API call, this ignores the response it only validates we are sending correct path/method/headers
Types ¶
type Context ¶
type Context struct { Env environmet.Env Log logr.Logger BeforeRequest func(*http.Request) Do func(*http.Request) (*http.Response, error) }
Context information needed to make a successful http api call.
func GetContext ¶
type Kase ¶
type Kase struct { Name string Request RequestKase Response *ResponseKase }
Kase a single test case for an API call.
type RequestKase ¶
Click to show internal directories.
Click to hide internal directories.