Documentation ¶
Overview ¶
Package api provides API and client to Cerberus.
Package api is a generated GoMock package.
Index ¶
- Constants
- Variables
- func Digest(r *http.Request) ([]byte, error)
- func IsAddressValid(s string) bool
- func Sign(r *http.Request, pk crypto.PrivKey) error
- func Verify(r *http.Request) ([]byte, error)
- type Cerberus
- type Error
- type MockCerberus
- func (m *MockCerberus) DoesPDVExist(ctx context.Context, address string) (bool, error)
- func (m *MockCerberus) EXPECT() *MockCerberusMockRecorder
- func (m *MockCerberus) ReceivePDV(ctx context.Context, address string) (json.RawMessage, error)
- func (m *MockCerberus) SavePDV(ctx context.Context, p *schema.PDV) (string, error)
- type MockCerberusMockRecorder
- type SavePDVResponse
Constants ¶
const PublicKeyHeader = "Public-Key"
PublicKeyHeader is name for public key http header.
const SignatureHeader = "Signature"
SignatureHeader is name for signature http header.
Variables ¶
var ErrInvalidPublicKey = fmt.Errorf("%w: public key is invalid", ErrInvalidRequest)
ErrInvalidPublicKey is returned when public key is invalid.
var ErrInvalidRequest = errors.New("invalid request")
ErrInvalidRequest is returned when request is invalid.
var ErrInvalidSignature = fmt.Errorf("%w: signature is invalid", ErrInvalidRequest)
ErrInvalidSignature is returned when signature is invalid.
var ErrNotFound = errors.New("not found")
ErrNotFound is returned when object is not found.
var ErrNotVerified = errors.New("failed to verify message")
ErrNotVerified is returned when signature is wrong.
Functions ¶
func IsAddressValid ¶
IsAddressValid check is address is matching with regexp.
Types ¶
type Cerberus ¶
type Cerberus interface { SavePDV(ctx context.Context, p *schema.PDV) (string, error) ReceivePDV(ctx context.Context, address string) (json.RawMessage, error) DoesPDVExist(ctx context.Context, address string) (bool, error) }
Cerberus provides user-friendly API methods.
func NewClient ¶
func NewClient(host string, pk secp256k1.PrivKeySecp256k1) Cerberus
NewClient returns client with http.DefaultClient.
func NewClientWithHTTPClient ¶
NewClientWithHTTPClient returns client with provided http.Client.
type MockCerberus ¶
type MockCerberus struct {
// contains filtered or unexported fields
}
MockCerberus is a mock of Cerberus interface
func NewMockCerberus ¶
func NewMockCerberus(ctrl *gomock.Controller) *MockCerberus
NewMockCerberus creates a new mock instance
func (*MockCerberus) DoesPDVExist ¶
DoesPDVExist mocks base method
func (*MockCerberus) EXPECT ¶
func (m *MockCerberus) EXPECT() *MockCerberusMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockCerberus) ReceivePDV ¶
func (m *MockCerberus) ReceivePDV(ctx context.Context, address string) (json.RawMessage, error)
ReceivePDV mocks base method
type MockCerberusMockRecorder ¶
type MockCerberusMockRecorder struct {
// contains filtered or unexported fields
}
MockCerberusMockRecorder is the mock recorder for MockCerberus
func (*MockCerberusMockRecorder) DoesPDVExist ¶
func (mr *MockCerberusMockRecorder) DoesPDVExist(ctx, address interface{}) *gomock.Call
DoesPDVExist indicates an expected call of DoesPDVExist
func (*MockCerberusMockRecorder) ReceivePDV ¶
func (mr *MockCerberusMockRecorder) ReceivePDV(ctx, address interface{}) *gomock.Call
ReceivePDV indicates an expected call of ReceivePDV
func (*MockCerberusMockRecorder) SavePDV ¶
func (mr *MockCerberusMockRecorder) SavePDV(ctx, p interface{}) *gomock.Call
SavePDV indicates an expected call of SavePDV
type SavePDVResponse ¶
type SavePDVResponse struct {
Address string `json:"address"`
}
SavePDVResponse ...