http

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2021 License: Apache-2.0 Imports: 14 Imported by: 5

Documentation

Index

Constants

View Source
const (

	// RejectionReasonHeader - This is used by authorization endpoints to provide a header that provides an error code
	// describing the different reasons an authorization can be denied.
	RejectionReasonHeaderExtension = "rejection_reason_header"
	// NoBodyExtension instructs backend to avoid generating response bodies for certain endpoints.
	// In particular, this is useful to avoid generating large response in the authorization endpoints
	NoBodyExtension = "no_body"
)

Variables

This section is empty.

Functions

func CodeToStatusCode added in v0.5.0

func CodeToStatusCode(errorCode string) int

CodeToStatusCode transforms a client response code to http status code. See https://github.com/3scale/apisonator/blob/v2.96.2/docs/rfcs/error_responses.md

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client interacts with 3scale Service Management API and implements a threescale client

func NewClient

func NewClient(backendURL string, httpClient *http.Client) (*Client, error)

NewClient returns a pointer to a Client providing some verification and sanity checking of the backendURL input. backendURL should take one of the following formats:

func NewDefaultClient

func NewDefaultClient() (*Client, error)

NewDefaultClient returns a pointer to Client which is configured for 3scale SaaS platform.

func (*Client) AuthRep

func (c *Client) AuthRep(apiCall threescale.Request) (*threescale.AuthorizeResult, error)

AuthRep should be used to authorize and report, in a single transaction for an application with the authentication provided in the transaction params

func (*Client) AuthRepWithOptions

func (c *Client) AuthRepWithOptions(apiCall threescale.Request, options ...Option) (*threescale.AuthorizeResult, error)

AuthRepWithOptions provides the same behaviour as AuthRep with additional functionality provided by Option(s)

func (*Client) Authorize

func (c *Client) Authorize(apiCall threescale.Request) (*threescale.AuthorizeResult, error)

Authorize is a read-only operation to authorize an application with the authentication provided in the transaction params

func (*Client) AuthorizeWithOptions

func (c *Client) AuthorizeWithOptions(apiCall threescale.Request, options ...Option) (*threescale.AuthorizeResult, error)

AuthorizeWithOptions provides the same behaviour as Authorize with additional functionality provided by Option(s)

func (*Client) GetPeer

func (c *Client) GetPeer() string

GetPeer returns the hostname of the backend for the client

func (*Client) GetVersion

func (c *Client) GetVersion() (string, error)

GetVersion returns the version of the backend for this client (remote call)

func (*Client) OauthAuthRep added in v0.5.1

func (c *Client) OauthAuthRep(apiCall threescale.Request) (*threescale.AuthorizeResult, error)

Deprecated - DO NOT use in new code.

func (*Client) OauthAuthRepWithOptions added in v0.5.1

func (c *Client) OauthAuthRepWithOptions(apiCall threescale.Request, options ...Option) (*threescale.AuthorizeResult, error)

Deprecated - DO NOT use in new code.

func (*Client) OauthAuthorize added in v0.5.1

func (c *Client) OauthAuthorize(apiCall threescale.Request) (*threescale.AuthorizeResult, error)

Deprecated - DO NOT use in new code.

func (*Client) OauthAuthorizeWithOptions added in v0.5.1

func (c *Client) OauthAuthorizeWithOptions(apiCall threescale.Request, options ...Option) (*threescale.AuthorizeResult, error)

Deprecated - DO NOT use in new code.

func (*Client) Report

func (c *Client) Report(apiCall threescale.Request) (*threescale.ReportResult, error)

func (*Client) ReportWithOptions

func (c *Client) ReportWithOptions(apiCall threescale.Request, options ...Option) (*threescale.ReportResult, error)

ReportWithOptions provides the same behaviour as Report with additional functionality provided by Option(s)

type InstrumentationCB

type InstrumentationCB func(ctx context.Context, hostName string, statusCode int, requestDuration time.Duration)

InstrumentationCB provides a callback hook into the client at response time to provide information about the underlying request to the remote host

type Option

type Option func(*Options)

Option defines a callback function which is used to provide functional options to a request

func WithContext

func WithContext(ctx context.Context) Option

WithContext wraps the http transaction to 3scale backend with the provided context

func WithInstrumentationCallback

func WithInstrumentationCallback(callback InstrumentationCB) Option

WithInstrumentationCallback allows the caller to provide an optional callback function that will be called in a separate goroutine, with the details of the underlying request to 3scale if present as an option

type Options

type Options struct {
	// contains filtered or unexported fields
}

Options to provide optional behaviour to the standard APIs for Authorize, AuthRep and Report

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL