Documentation
¶
Overview ¶
Package apix provide API-related helpers.
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 UserAgent ¶ added in v0.5.0
type UserAgent struct {
Client *http.Client // Default: &http.Client{}. Feel free to change as needed.
// contains filtered or unexported fields
}
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.
func (*UserAgent) Do ¶ added in v0.5.0
func (x *UserAgent) Do(ctx Ctx, req *http.Request, skip int) (_ *http.Response, body []byte, _ error)
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.
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.