rest

package
v0.0.0-...-667e438 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2019 License: Apache-2.0 Imports: 23 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.

Functions

func StartOpenchainRESTServer

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

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

Types

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