Skip to content

Latest commit

 

History

History
404 lines (231 loc) · 11.4 KB

api.md

File metadata and controls

404 lines (231 loc) · 11.4 KB

api

import "Smilo-blackbox/src/server/api"

common.go log.go private.go public.go types.go

func API(w http.ResponseWriter, r *http.Request)

API Request path "/api", response json rest api spec.

func ConfigPeersGet(w http.ResponseWriter, r *http.Request)

ConfigPeersGet Receive a GET request with index on path and return Status Code 200 and Peer json containing url, Status Code 404 if not found.

func ConfigPeersPut(w http.ResponseWriter, r *http.Request)

ConfigPeersPut It receives a PUT request with a json containing a Peer url and returns Status Code 200.

func Delete(w http.ResponseWriter, r *http.Request)

Delete Deprecated API It receives a POST request with a json containing a DeleteRequest with key and returns Status 200 if succeed, 404 otherwise.

func GetPartyInfo(w http.ResponseWriter, r *http.Request)

GetPartyInfo It receives a POST request with a json containing url and key, returns local publicKeys and a proof that private key is known.

func GetVersion(w http.ResponseWriter, r *http.Request)

GetVersion Request path "/version", response plain text version ID

func Metrics(w http.ResponseWriter, r *http.Request)

Metrics Receive a GET request and return Status Code 200 and server internal status information in plain text.

func Push(w http.ResponseWriter, r *http.Request)

Push It receives a POST request with a payload and returns Status Code 201 with a payload generated hash, on error returns Status Code 500.

func PushTransactionForOtherNodes(encryptedTransaction data.EncryptedTransaction, recipient []byte)

PushTransactionForOtherNodes will push encrypted transaction to other nodes

func Receive(w http.ResponseWriter, r *http.Request)

Receive is a Deprecated API It receives a ReceiveRequest json with an encoded key (hash) and to values, returns decrypted payload

func ReceiveRaw(w http.ResponseWriter, r *http.Request)

ReceiveRaw Receive a GET request with header params bb0x-key and bb0x-to, return unencrypted payload

func Resend(w http.ResponseWriter, r *http.Request)

Resend It receives a POST request with a json ResendRequest containing type (INDIVIDUAL, ALL), publicKey and key(for individual requests), it returns encoded payload for INDIVIDUAL or it does one push request for each payload and returns empty for type ALL.

func RetrieveAndDecryptPayload(w http.ResponseWriter, r *http.Request, key []byte, to []byte) []byte

RetrieveAndDecryptPayload will retrieve and decrypt the payload

func RetrieveJSONPayload(w http.ResponseWriter, r *http.Request, key []byte, to []byte)

RetrieveJSONPayload will retrieve payload based on request

func Send(w http.ResponseWriter, r *http.Request)

Send It receives json SendRequest with from, to and payload, returns Status Code 200 and json KeyJSON with encoded key.

func SendRaw(w http.ResponseWriter, r *http.Request)

SendRaw It receives headers "bb0x-from" and "bb0x-to", payload body and returns Status Code 200 and encoded key plain text.

func SendSignedTx(w http.ResponseWriter, r *http.Request)

SendSignedTx It receives header "bb0x-to" and raw transaction hash body and returns Status Code 200 and transaction hash.

func SetLogger(loggers *logrus.Entry)

SetLogger set the logger

func StoreRaw(w http.ResponseWriter, r *http.Request)

StoreRaw It receives a POST request with a payload and returns Status Code 201 with a payload generated hash, on error returns Status Code 500.

func TransactionDelete(w http.ResponseWriter, r *http.Request)

TransactionDelete It receives a DELETE request with a key on path string and returns 204 if succeed, 404 otherwise.

func TransactionGet(w http.ResponseWriter, r *http.Request)

TransactionGet it receives a GET request with a hash on path and query var "to" with encoded hash and to, returns decrypted payload

func UnknownRequest(w http.ResponseWriter, r *http.Request)

UnknownRequest will debug unknown reqs

func Upcheck(w http.ResponseWriter, r *http.Request)

Upcheck Request path "/upcheck", response plain text upcheck message.

type KeyJSON struct {
    // Key is the key that can be used to retrieve the submitted transaction.
    Key string `json:"key"`
}

KeyJSON marshal/unmarshal a key

type PeerURL struct {
    URL string `json:"url"`
}

PeerURL will marshal/unmarshal url

type ReceiveRequest struct {
    Key string `json:"key"`
    To  string `json:"to"`
}

ReceiveRequest marshal/unmarshal key and to

func (*ReceiveRequest) Parse

func (e *ReceiveRequest) Parse() ([]byte, []byte, []string)

Parse will process receiving parsing

type ReceiveResponse struct {
    Payload string `json:"payload"`
}

ReceiveResponse will marshal/unmarshal payload

type ResendRequest struct {
    // Type is the resend request type. It should be either "all" or "individual" depending on if
    // you want to request an individual transaction, or all transactions associated with a node.
    Type      string `json:"type"`
    PublicKey string `json:"publicKey"`
    Key       string `json:"key,omitempty"`
}

ResendRequest will marshal/unmarshal type, pub and pk

type SendRequest struct {
    // Payload is the transaction payload data we wish to store.
    Payload string `json:"payload"`
    // From is the sender node identification.
    From string `json:"from"`
    // To is a list of the recipient nodes that should be privy to this transaction payload.
    To []string `json:"to"`
}

SendRequest will marshal/unmarshal payload from and to

func (*SendRequest) Parse

func (e *SendRequest) Parse() ([]byte, []byte, [][]byte, []string)

Parse will process send parsing

type StoreRawRequest struct {
    Payload string `json:"payload"`
    From    string `json:"from,omitempty"`
}

StoreRawRequest will marshal/unmarshal payload and from


Generated by godoc2md