Documentation
¶
Index ¶
- func ErrorHandler(w http.ResponseWriter, r *http.Request)
- type AuthPayload
- type BlockInfo
- type BlockchainInfo
- type CustomClaims
- type HTTPHandler
- func (h HTTPHandler) AccountGet(w http.ResponseWriter, r *http.Request)
- func (h *HTTPHandler) AccountRegistration(w http.ResponseWriter, r *http.Request)
- func (h *HTTPHandler) AccountUpdate(w http.ResponseWriter, r *http.Request)
- func (h HTTPHandler) CollectionList(w http.ResponseWriter, r *http.Request)
- func (h *HTTPHandler) CollectionMappingCreation(w http.ResponseWriter, r *http.Request)
- func (h HTTPHandler) CollectionMappingGet(w http.ResponseWriter, r *http.Request)
- func (h HTTPHandler) HandleBlockInfo(w http.ResponseWriter, r *http.Request)
- func (h HTTPHandler) HandleInfo(w http.ResponseWriter, r *http.Request)
- func (h HTTPHandler) HandleJWT(w http.ResponseWriter, r *http.Request)
- func (h HTTPHandler) HandleMerklePath(w http.ResponseWriter, r *http.Request)
- func (h HTTPHandler) HandlePeers(w http.ResponseWriter, r *http.Request)
- func (h HTTPHandler) HandleSearch(w http.ResponseWriter, r *http.Request)
- func (h *HTTPHandler) HandleTransaction(w http.ResponseWriter, r *http.Request)
- func (h HTTPHandler) HandleTransactionBulk(w http.ResponseWriter, r *http.Request)
- func (h HTTPHandler) JWTChallenge(w http.ResponseWriter, r *http.Request)
- func (h HTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (h HTTPHandler) SetAccountReadWrite(w http.ResponseWriter, r *http.Request)
- type SearchResponse
- type TransactionBulkCreationResponse
- type TransactionCreationResponse
- type TransactionPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorHandler ¶
func ErrorHandler(w http.ResponseWriter, r *http.Request)
ErrorHandler handles non-existing route
Types ¶
type AuthPayload ¶ added in v0.1.0
type AuthPayload struct { Signature string `json:"signature"` Address string `json:"address"` ChallengeWord string `json:"challengeWord"` }
AuthPayload defines the data for HTTP clients should provide to obtain a JWT
type BlockInfo ¶
type BlockInfo struct { BlockchainId string `json:"blockchainId"` BlockId string `json:"blockId"` PrevBlockId string `json:"prevBlockId"` BlockHeight uint64 `json:"blockHeight"` TotalTransactions int `json:"totalTransactions"` }
BlockInfo has information about a certain block
type BlockchainInfo ¶
type BlockchainInfo struct { BlockchainId string `json:"blockchainId"` TipBlockId string `json:"tipBlockId"` LastHeight int `json:"lastHeight"` TotalTransactions int64 `json:"totalTransactions"` }
BlockchainInfo has current status information about the whole blockchain
type CustomClaims ¶
type CustomClaims struct { RoleName string `json:"roleName"` Address string `json:"address"` jwt.StandardClaims }
CustomClaims is the customized claim based on the standard JWT claims
type HTTPHandler ¶
type HTTPHandler struct {
// contains filtered or unexported fields
}
HTTPHandler encapsulates the essential objects to serve http requests
func NewHTTPHandler ¶
func NewHTTPHandler(bf *p2p.BlockchainForest, r *pool.Receiver, p *p2p.P2P, secret string, version string) HTTPHandler
NewHTTPHandler create a new instance of HTTPHandler
func (HTTPHandler) AccountGet ¶
func (h HTTPHandler) AccountGet(w http.ResponseWriter, r *http.Request)
AccountGet returns an account's information for a given address
func (*HTTPHandler) AccountRegistration ¶
func (h *HTTPHandler) AccountRegistration(w http.ResponseWriter, r *http.Request)
AccountRegistration register the account information
{ "dateOfBirth": "2018-10-01", "firstName": "Hooper", "lastName": "Vincent", "organization": "MITROC", "position": "VP of Marketing", "email": "hoopervincent@mitroc.com", "phone": "+1 (849) 503-2756", "address": "699 Canton Court, Mulino, South Dakota, 9647", "publicKey":"e4a15344314a15c70a47e18fadc8117939a6dc5ed863ced84a898694b241d10fa129eff3989ec98393c52bac6d86d0d72534061538eb1e513aaae4def5f83fbb" }
func (*HTTPHandler) AccountUpdate ¶
func (h *HTTPHandler) AccountUpdate(w http.ResponseWriter, r *http.Request)
AccountUpdate updates an existing account's information
{ "dateOfBirth": "2018-10-01", "firstName": "Hooper", "lastName": "Vincent", "organization": "MITROC", "position": "VP of Marketing", "email": "hoopervincent@mitroc.com", "phone": "+1 (849) 503-2756", "address": "699 Canton Court, Mulino, South Dakota, 9647" }
func (HTTPHandler) CollectionList ¶
func (h HTTPHandler) CollectionList(w http.ResponseWriter, r *http.Request)
CollectionList returns the all the collection names
func (*HTTPHandler) CollectionMappingCreation ¶
func (h *HTTPHandler) CollectionMappingCreation(w http.ResponseWriter, r *http.Request)
CollectionMappingCreation handles the creation of the collection (and index mapping)
func (HTTPHandler) CollectionMappingGet ¶
func (h HTTPHandler) CollectionMappingGet(w http.ResponseWriter, r *http.Request)
CollectionMappingGet returns the collection mapping definition
func (HTTPHandler) HandleBlockInfo ¶
func (h HTTPHandler) HandleBlockInfo(w http.ResponseWriter, r *http.Request)
HandleBlockInfo returns the general information of a blockchain's block
func (HTTPHandler) HandleInfo ¶
func (h HTTPHandler) HandleInfo(w http.ResponseWriter, r *http.Request)
HandleInfo returns the basic information of the blockchain
func (HTTPHandler) HandleJWT ¶
func (h HTTPHandler) HandleJWT(w http.ResponseWriter, r *http.Request)
HandleJWT checks the credentials and return corresponding JWT
{ "address": "0x07322C5A59047c09e87C284503F64f7FdDD17aBd", "challengeWord": "R7be38YqgP74w4U2jpOVgXfQWqkjQyNGiHhHpuRSVVDeUVPs8DDcgbzz3fbFll9o" "signature": "6b2064ddf73f7b96559ecae424b3b657d1daf62078305e92af991c22e04808d476e8161ec7be58324b662042965a9935de8fb697eb3df7afad5d1885f129f666" }
func (HTTPHandler) HandleMerklePath ¶
func (h HTTPHandler) HandleMerklePath(w http.ResponseWriter, r *http.Request)
HandleMerklePath returns the necessary transaction hashes for clients to verify if a transaction has been included in the block
func (HTTPHandler) HandlePeers ¶ added in v0.1.0
func (h HTTPHandler) HandlePeers(w http.ResponseWriter, r *http.Request)
HandlePeers returns all the alive peers of the current node
func (HTTPHandler) HandleSearch ¶
func (h HTTPHandler) HandleSearch(w http.ResponseWriter, r *http.Request)
HandleSearch handles the search queries against the search engine
{ "size": 10, "explain": true, "highlight": {}, "query": { "boost": 1, "match": "Canada", "field": "country", "prefix_length": 0, "fuzziness": 0 } }
func (*HTTPHandler) HandleTransaction ¶
func (h *HTTPHandler) HandleTransaction(w http.ResponseWriter, r *http.Request)
HandleTransaction put and index new transaction
{ "rawDocument": "{\"id\":\"10001\",\"message\":\"Send 10000 BTC to Ivan\"}", "signature": "8e0063b76c2aed4982e1b62c713b0a7cf74f2b548b8c032659da65404c3d0b9777b8f8613f3e87e43680ec638949e263658ef5608bad7359e1075e285f49dd8d", "permittedAddresses" : ["0x07322C5A59047c09e87C284503F64f7FdDD17aBd", "0x931D387731bBbC988B312206c74F77D004D6B84b"] }
func (HTTPHandler) HandleTransactionBulk ¶
func (h HTTPHandler) HandleTransactionBulk(w http.ResponseWriter, r *http.Request)
HandleTransactionBulk put and index new transactions in bulk. Transactions payload don't need signatures. [
{ "id": "10001", "message": "Send 1 BTC to Ivan" }, { "id": "10002", "message": "Send 2 BTC to Ivan" }, { "id": "10003", "message": "Send 3 BTC to Ivan" }, { "id": "10004", "message": "Send 4 BTC to Ivan" }
] WARNING: this makes the document unverifiable
func (HTTPHandler) JWTChallenge ¶
func (h HTTPHandler) JWTChallenge(w http.ResponseWriter, r *http.Request)
JWTChallenge creates a random challenge word for the clients to sign
func (HTTPHandler) ServeHTTP ¶
func (h HTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (HTTPHandler) SetAccountReadWrite ¶
func (h HTTPHandler) SetAccountReadWrite(w http.ResponseWriter, r *http.Request)
SetAccountReadWrite set the user's collection-level read override and write permission
{ "collectionsWrite": ["default", "collection1"], "collectionsReadOverride": ["default", "collection2"] }
type SearchResponse ¶
type SearchResponse struct { Collection string `json:"collection"` Status *bleve.SearchStatus `json:"status"` Total uint64 `json:"total_hits"` Hits []blockchain.Document `json:"hits"` }
SearchResponse determines the data in the HTTP response that the HTTP client gets
type TransactionBulkCreationResponse ¶
type TransactionBulkCreationResponse struct { Status string `json:"status"` Total int `json:"total"` Accepted int `json:"accepted"` Dropped int `json:"dropped"` FieldErrorMapping map[string]string `json:"fieldErrors"` }
TransactionBulkCreationResponse has the validation and count information from the server to the HTTP clients
type TransactionCreationResponse ¶
type TransactionCreationResponse struct { Status string `json:"status"` FieldErrorMapping map[string]string `json:"fieldErrors"` IsValidSignature bool `json:"isValidSignature"` TransactionID string `json:"transactionID"` }
TransactionCreationResponse has the validation information from the server to the HTTP clients
type TransactionPayload ¶
type TransactionPayload struct { RawDocument string `json:"rawDocument"` Signature string `json:"signature"` Address string `json:"address"` PermittedAddresses []string `json:"permittedAddresses"` }
TransactionPayload defines the data for HTTP clients should provide to add a document to the blockchain