Documentation ¶
Index ¶
- Variables
- func AddHeaders(q map[string]string) func(*http.Request)
- func AddQuery(q map[string]string) func(*http.Request)
- func Do(r *http.Request) (*http.Response, error)
- func Error(res *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 RunRequestKase(t *testing.T, e environmet.Env, fn func(Client) error, kase ...Kase)
- func SetHeaders(q map[string]string) func(*http.Request)
- type Client
- func (c Client) Call(method, url string, body io.Reader, fn ...func(*http.Request)) (*http.Response, error)
- func (c Client) Delete(url string, body io.Reader, fn ...func(*http.Request)) (*http.Response, error)
- func (c Client) Environment() environmet.Env
- func (c Client) Get(url string, body io.Reader, fn ...func(*http.Request)) (*http.Response, error)
- func (c Client) JSON(method, url string, body interface{}, fn ...func(*http.Request)) (*http.Response, error)
- func (c Client) Post(url string, body io.Reader, fn ...func(*http.Request)) (*http.Response, error)
- func (c Client) PostJSON(url string, body interface{}, fn ...func(*http.Request)) (*http.Response, error)
- func (c Client) PutJSON(url string, body interface{}, fn ...func(*http.Request)) (*http.Response, error)
- func (c Client) Request(method, url string, body io.Reader) (*http.Request, error)
- type Kase
- type RequestKase
- type ResponseKase
- type UniversalApi
- type UniversalCertificate
- type UniversalClient
- type UniversalSecurityPolicy
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("Resource not found")
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 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 Client ¶
type Client struct { Env environmet.Env Log logr.Logger BeforeRequest func(*http.Request) Do func(*http.Request) (*http.Response, error) }
func (Client) Environment ¶
func (c Client) Environment() environmet.Env
type Kase ¶
type Kase struct { Name string Request RequestKase Response *ResponseKase }
Kase a single test case for an API call.
type RequestKase ¶
type ResponseKase ¶
type UniversalApi ¶
type UniversalApi interface { Get(ctx context.Context, apiID string) (*v1.APIDefinitionSpec, error) All(ctx context.Context) ([]v1.APIDefinitionSpec, error) Create(ctx context.Context, spec *v1.APIDefinitionSpec) error Update(ctx context.Context, def *v1.APIDefinitionSpec) error Delete(ctx context.Context, id string) error }
type UniversalCertificate ¶
type UniversalCertificate interface { All(ctx context.Context) ([]string, error) Upload(ctx context.Context, key []byte, crt []byte) (id string, err error) Delete(ctx context.Context, id string) error // Exists returns true if a certificate with id exists Exists(ctx context.Context, id string) bool }
type UniversalClient ¶
type UniversalClient interface { Environment() environmet.Env HotReload() error Api() UniversalApi SecurityPolicy() UniversalSecurityPolicy Certificate() UniversalCertificate }
type UniversalSecurityPolicy ¶
type UniversalSecurityPolicy interface { All(ctx context.Context) ([]tykv1alpha1.SecurityPolicySpec, error) // Get retruns the policy with the given id. Get(ctx context.Context, id string) (*tykv1alpha1.SecurityPolicySpec, error) // Create creates a new def and updates id and other fields. It is up to the // caller to update any fields that will be set after the policy has been // created for instance _id Create(ctx context.Context, def *tykv1alpha1.SecurityPolicySpec) error // Update this will update an existing policy Update(ctx context.Context, def *tykv1alpha1.SecurityPolicySpec) error //Delete deletes policy id id Delete(ctx context.Context, id string) error }
Click to show internal directories.
Click to hide internal directories.