rest

package
v0.0.0-...-82629c9 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Pre-defined errors and messages.
	ParseError     = &rpcError{Code: -32700, Message: "Parse error", Data: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."}
	InvalidRequest = &rpcError{Code: -32600, Message: "Invalid request", Data: "The JSON sent is not a valid Request object."}
	MethodNotFound = &rpcError{Code: -32601, Message: "Method not found", Data: "The method does not exist / is not available."}
	InvalidParams  = &rpcError{Code: -32602, Message: "Invalid params", Data: "Invalid method parameter(s)."}
	InternalError  = &rpcError{Code: -32603, Message: "Internal error", Data: "Internal JSON-RPC error."}

	// -32000 to -32099	 - Server error. Reserved for implementation-defined server-errors.
	MissingRegistrationError = &rpcError{Code: -32000, Message: "Registration missing", Data: "User not logged in. Use the '/registrar' endpoint to obtain a security token."}
	ChaincodeDeployError     = &rpcError{Code: -32001, Message: "Deployment failure", Data: "Chaincode deployment has failed."}
	ChaincodeInvokeError     = &rpcError{Code: -32002, Message: "Invocation failure", Data: "Chaincode invocation has failed."}
	ChaincodeQueryError      = &rpcError{Code: -32003, Message: "Query failure", Data: "Chaincode query has failed."}
)

JSON RPC 2.0 errors and messages.

View Source
var (
	// ErrNotFound is returned if a requested resource does not exist
	ErrNotFound = errors.New("openchain: resource not found")
)

Functions

func StartOpenchainRESTServer

func StartOpenchainRESTServer(server *ServerOpenchain, devops *core.Devops)

StartOpenchainRESTServer initializes the REST service and adds the required middleware and routes.

Types

type PeerInfo

type PeerInfo interface {
	GetPeers() (*pb.PeersMessage, error)
	GetPeerEndpoint() (*pb.PeerEndpoint, error)
}

PeerInfo defines API to peer info data

type ServerOpenchain

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

ServerOpenchain defines the Openchain server object, which holds the Ledger data structure and the pointer to the peerServer.

func NewOpenchainServer

func NewOpenchainServer() (*ServerOpenchain, error)

NewOpenchainServer creates a new instance of the ServerOpenchain.

func NewOpenchainServerWithPeerInfo

func NewOpenchainServerWithPeerInfo(peerServer PeerInfo) (*ServerOpenchain, error)

NewOpenchainServerWithPeerInfo creates a new instance of the ServerOpenchain.

func (*ServerOpenchain) GetBlockByNumber

func (s *ServerOpenchain) GetBlockByNumber(ctx context.Context, num *pb.BlockNumber) (*pb.Block, error)

GetBlockByNumber returns the data contained within a specific block in the blockchain. The genesis block is block zero.

func (*ServerOpenchain) GetBlockCount

func (s *ServerOpenchain) GetBlockCount(ctx context.Context, e *empty.Empty) (*pb.BlockCount, error)

GetBlockCount returns the current number of blocks in the blockchain data structure.

func (*ServerOpenchain) GetBlockchainInfo

func (s *ServerOpenchain) GetBlockchainInfo(ctx context.Context, e *empty.Empty) (*pb.BlockchainInfo, error)

GetBlockchainInfo returns information about the blockchain ledger such as height, current block hash, and previous block hash.

func (*ServerOpenchain) GetPeerEndpoint

func (s *ServerOpenchain) GetPeerEndpoint(ctx context.Context, e *empty.Empty) (*pb.PeersMessage, error)

GetPeerEndpoint returns PeerEndpoint info of target peer.

func (*ServerOpenchain) GetPeers

func (s *ServerOpenchain) GetPeers(ctx context.Context, e *empty.Empty) (*pb.PeersMessage, error)

GetPeers returns a list of all peer nodes currently connected to the target peer.

func (*ServerOpenchain) GetState

func (s *ServerOpenchain) GetState(ctx context.Context, chaincodeID, key string) ([]byte, error)

GetState returns the value for a particular chaincode ID and key

func (*ServerOpenchain) GetTransactionByID

func (s *ServerOpenchain) GetTransactionByID(ctx context.Context, txID string) (*pb.Transaction, error)

GetTransactionByID returns a transaction matching the specified ID

type ServerOpenchainREST

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

ServerOpenchainREST defines the Openchain REST service object. It exposes the methods available on the ServerOpenchain service and the Devops service through a REST API.

func (*ServerOpenchainREST) DeleteEnrollmentID

func (s *ServerOpenchainREST) DeleteEnrollmentID(rw web.ResponseWriter, req *web.Request)

DeleteEnrollmentID removes the login token of the specified user from the Devops server. Once the login token is removed, the specified user will no longer be able to transact without logging in again. On the REST interface, this method may be used as a means of logging out an active client.

func (*ServerOpenchainREST) Deploy deprecated

func (s *ServerOpenchainREST) Deploy(rw web.ResponseWriter, req *web.Request)

Deploy first builds the chaincode package and subsequently deploys it to the blockchain.

Deprecated: use the /chaincode endpoint instead (routes to ProcessChaincode)

func (*ServerOpenchainREST) GetBlockByNumber

func (s *ServerOpenchainREST) GetBlockByNumber(rw web.ResponseWriter, req *web.Request)

GetBlockByNumber returns the data contained within a specific block in the blockchain. The genesis block is block zero.

func (*ServerOpenchainREST) GetBlockchainInfo

func (s *ServerOpenchainREST) GetBlockchainInfo(rw web.ResponseWriter, req *web.Request)

GetBlockchainInfo returns information about the blockchain ledger such as height, current block hash, and previous block hash.

func (*ServerOpenchainREST) GetEnrollmentCert

func (s *ServerOpenchainREST) GetEnrollmentCert(rw web.ResponseWriter, req *web.Request)

GetEnrollmentCert retrieves the enrollment certificate for a given user.

func (*ServerOpenchainREST) GetEnrollmentID

func (s *ServerOpenchainREST) GetEnrollmentID(rw web.ResponseWriter, req *web.Request)

GetEnrollmentID checks whether a given user has already registered with the Devops server.

func (*ServerOpenchainREST) GetPeers

func (s *ServerOpenchainREST) GetPeers(rw web.ResponseWriter, req *web.Request)

GetPeers returns a list of all peer nodes currently connected to the target peer, including itself

func (*ServerOpenchainREST) GetTransactionByID

func (s *ServerOpenchainREST) GetTransactionByID(rw web.ResponseWriter, req *web.Request)

GetTransactionByID returns a transaction matching the specified ID

func (*ServerOpenchainREST) GetTransactionCert

func (s *ServerOpenchainREST) GetTransactionCert(rw web.ResponseWriter, req *web.Request)

GetTransactionCert retrieves the transaction certificate(s) for a given user.

func (*ServerOpenchainREST) Invoke deprecated

func (s *ServerOpenchainREST) Invoke(rw web.ResponseWriter, req *web.Request)

Invoke executes a specified function within a target Chaincode.

Deprecated: use the /chaincode endpoint instead (routes to ProcessChaincode)

func (*ServerOpenchainREST) NotFound

func (s *ServerOpenchainREST) NotFound(rw web.ResponseWriter, r *web.Request)

NotFound returns a custom landing page when a given hyperledger end point had not been defined.

func (*ServerOpenchainREST) ProcessChaincode

func (s *ServerOpenchainREST) ProcessChaincode(rw web.ResponseWriter, req *web.Request)

ProcessChaincode implements JSON RPC 2.0 specification for chaincode deploy, invoke, and query.

func (*ServerOpenchainREST) Query deprecated

func (s *ServerOpenchainREST) Query(rw web.ResponseWriter, req *web.Request)

Query performs the requested query on the target Chaincode.

Deprecated: use the /chaincode endpoint instead (routes to ProcessChaincode)

func (*ServerOpenchainREST) Register

func (s *ServerOpenchainREST) Register(rw web.ResponseWriter, req *web.Request)

Register confirms the enrollmentID and secret password of the client with the CA and stores the enrollment certificate and key in the Devops server.

func (*ServerOpenchainREST) SetOpenchainServer

func (s *ServerOpenchainREST) SetOpenchainServer(rw web.ResponseWriter, req *web.Request, next web.NextMiddlewareFunc)

SetOpenchainServer is a middleware function that sets the pointer to the underlying ServerOpenchain object and the undeflying Devops object.

func (*ServerOpenchainREST) SetResponseType

func (s *ServerOpenchainREST) SetResponseType(rw web.ResponseWriter, req *web.Request, next web.NextMiddlewareFunc)

SetResponseType is a middleware function that sets the appropriate response headers. Currently, it is setting the "Content-Type" to "application/json" as well as the necessary headers in order to enable CORS for Swagger usage.

Jump to

Keyboard shortcuts

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