Documentation ¶
Index ¶
- func NewReqAuditor(auditor Auditor, userID, action string) *reqAuditor
- type Auditor
- type Authorization
- type BearerAuthorization
- type Error
- type Float
- type Request
- func (r *Request) Delete(ctx context.Context, path string) (interface{}, error)
- func (r *Request) Get(ctx context.Context, path string) (interface{}, error)
- func (r *Request) Post(ctx context.Context, path string) (interface{}, error)
- func (r *Request) Request(ctx context.Context, method, path string) (*http.Request, error)
- func (r *Request) WithAuditor(a RequestAuditor) *Request
- func (r *Request) WithAuthorization(a Authorization) *Request
- func (r *Request) WithFormBody(vals url.Values) *Request
- func (r *Request) WithHeader(key, value string) *Request
- func (r *Request) WithHeaders(headers url.Values) *Request
- func (r *Request) WithJSONBody(obj interface{}) *Request
- func (r *Request) WithQParam(key, value string) *Request
- func (r *Request) WithQParamPtr(key string, value *string) *Request
- func (r *Request) WithResult(result interface{}) *Request
- type RequestAuditor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewReqAuditor ¶
Types ¶
type Auditor ¶
type Auditor interface { // UserSuccess audits the requests and response when the http status // code is <300. UserSuccess(userID, action string, metadata map[string]interface{}) // UserFail audits the requests and response when the http status // code is >=300. UserFail(userID, action string, metadata map[string]interface{}) }
type Authorization ¶
type Authorization interface { // Authorize is called after everything is set to the http.Request // and before making the request, so everything needed to authorize // it is added. Authorize(req *http.Request) (*http.Request, error) }
Authorization adds the authorization to the http.Request. It should change the http.Request to include whatever needs to be added.
type BearerAuthorization ¶
type BearerAuthorization struct {
// contains filtered or unexported fields
}
BearerAuthorization authorizes http requests with a bearer token.
func NewBearerAuth ¶
func NewBearerAuth(accessToken string) *BearerAuthorization
NewBearerAuth returns a new BearerAuthorization.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request makes a new http Request with the params, headers and body set.
func NewRequest ¶
NewRequest returns a new request.
func (*Request) WithAuditor ¶
func (r *Request) WithAuditor(a RequestAuditor) *Request
func (*Request) WithAuthorization ¶
func (r *Request) WithAuthorization(a Authorization) *Request
func (*Request) WithHeader ¶
func (*Request) WithJSONBody ¶
func (*Request) WithQParam ¶
WithQParam adds a query parameter to the requests.
func (*Request) WithResult ¶
type RequestAuditor ¶
type RequestAuditor interface { // SetReq sets the HTTP request to the provider to be audited. SetReq(req *http.Request) // SetResp sets the HTTP response from the provider to be audited. SetResp(resp *http.Response) // Audit sends the audit trail to the Auditor. Audit() }
RequestAuditor audits the http requests and corresponding response.
Click to show internal directories.
Click to hide internal directories.