Documentation ¶
Overview ¶
Package apix provide API-related helpers.
Package apix is a generated GoMock package.
Package apix is a generated GoMock package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrAccessTokenInvalid = errors.New("invalid AccessToken")
)
Errors.
Functions ¶
Types ¶
type AccessToken ¶
type AccessToken string
AccessToken is an access token.
func AccessTokenFromContext ¶ added in v0.3.0
func AccessTokenFromContext(ctx Ctx) (accessToken AccessToken)
AccessTokenFromContext returns AccessToken stored in ctx, if any.
func (AccessToken) Format ¶ added in v0.3.0
func (s AccessToken) Format(f fmt.State, c rune)
Format wraps sensitive.String.
func (AccessToken) MarshalJSON ¶ added in v0.3.0
func (s AccessToken) MarshalJSON() ([]byte, error)
MarshalJSON wraps sensitive.String.
func (AccessToken) MarshalText ¶ added in v0.3.0
func (s AccessToken) MarshalText() ([]byte, error)
MarshalText wraps sensitive.String.
type Authn ¶
type Authn interface { // Authenticate validates AccessToken and returns corresponding // Auth. If validation fails returns zero Auth with error. // // Errors: ErrAccessTokenInvalid. Authenticate(Ctx, AccessToken) (dom.Auth, error) }
Authn validates AccessToken.
type JSONRPC2Ctx ¶ added in v0.3.0
JSONRPC2Ctx describe JSON-RPC 2.0 Ctx param used by all API methods.
func (*JSONRPC2Ctx) NewContext ¶ added in v0.3.0
func (c *JSONRPC2Ctx) NewContext( authn Authn, service string, ) ( ctx Ctx, log *structlog.Logger, methodName string, auth dom.Auth, err error, )
NewContext returns a new context.Context that carries values describing this request without any deadline, plus some of the values.
type MockAuthn ¶
type MockAuthn struct {
// contains filtered or unexported fields
}
MockAuthn is a mock of Authn interface.
func NewMockAuthn ¶
func NewMockAuthn(ctrl *gomock.Controller) *MockAuthn
NewMockAuthn creates a new mock instance.
func (*MockAuthn) Authenticate ¶
Authenticate mocks base method.
func (*MockAuthn) EXPECT ¶
func (m *MockAuthn) EXPECT() *MockAuthnMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockAuthnMockRecorder ¶
type MockAuthnMockRecorder struct {
// contains filtered or unexported fields
}
MockAuthnMockRecorder is the mock recorder for MockAuthn.
func (*MockAuthnMockRecorder) Authenticate ¶
func (mr *MockAuthnMockRecorder) Authenticate(arg0, arg1 interface{}) *gomock.Call
Authenticate indicates an expected call of Authenticate.
type MockUserAgent ¶ added in v0.5.2
type MockUserAgent struct {
// contains filtered or unexported fields
}
MockUserAgent is a mock of UserAgent interface.
func NewMockUserAgent ¶ added in v0.5.2
func NewMockUserAgent(ctrl *gomock.Controller) *MockUserAgent
NewMockUserAgent creates a new mock instance.
func (*MockUserAgent) EXPECT ¶ added in v0.5.2
func (m *MockUserAgent) EXPECT() *MockUserAgentMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockUserAgentMockRecorder ¶ added in v0.5.2
type MockUserAgentMockRecorder struct {
// contains filtered or unexported fields
}
MockUserAgentMockRecorder is the mock recorder for MockUserAgent.
func (*MockUserAgentMockRecorder) Do ¶ added in v0.5.2
func (mr *MockUserAgentMockRecorder) Do(ctx, req, skip interface{}) *gomock.Call
Do indicates an expected call of Do.
func (*MockUserAgentMockRecorder) Log ¶ added in v0.5.2
func (mr *MockUserAgentMockRecorder) Log(ctx, resp, body interface{}) *gomock.Call
Log indicates an expected call of Log.
type UserAgent ¶ added in v0.5.0
type UserAgent interface { // Do sends an HTTP request and returns an HTTP response. // It returns body for convenience - it's same as can be read from resp.Body. // It saves body to file if log level is Debug and cfg.Debug and cfg.DumpDir is set. // Returned resp.Body doesn't needs to be closed. Do(ctx Ctx, req *http.Request, skip int) (_ *http.Response, body []byte, _ error) // Log resp (both HTTP request and response). // It does nothing if cfg.Debug is false. Log(ctx Ctx, resp *http.Response, body []byte) }
UserAgent is a convenience wrapper for http.Client, suitable for fetching small responses (because it reads full response in memory).
func NewUserAgent ¶ added in v0.5.0
func NewUserAgent(cfg UserAgentConfig) UserAgent
NewUserAgent creates and returns new UserAgent.
type UserAgentConfig ¶ added in v0.5.0
type UserAgentConfig struct { Timeout time.Duration // Default: 30s. MaxBodySize int // Default: 1MB. Debug bool // Log response. DumpDir string // If not empty and Debug - dump response body to files in this dir. }
UserAgentConfig contains configuration for UserAgent.