Learn about ame component
GET
, POST
, and PUT
are set. The functions of each need to be defined in these three types to facilitate the contract caller to understand and process the information required for the request. However, there is no DELETE
operation type because deleting data in the contract is an inefficient operation. Developers can add a PUT
request method by themselves to set the data to be valid and invalid, and only return valid data in the GET
method.
constructor
and then obtained according to the method name through getMethodReqAndRes
. The data type of the parameter is defined by the enumeration of the data type. When processing the request parameter, abi.decode
is used to decode according to the request parameter type and the request value. When returning the response, abi.encode
is used to encode according to the response value and the response parameter type. In addition, we can get the method usage instructions by calling getMethodInstruction
.
Types.sol
contains an enumeration of Solidity types used in the above interfaces.
getMethods
Get method names based on request method type.getMethodReqAndRes
Get the data types of request parameters and return parameters based on the requested method name.getMethodInstruction
Get the instruction of method.get
Request the contract to retrieve records.post
Request the contract to create a new record.put
Request the contract to update a record.options
Supported request method types.methodRequests
and methodResponses
are used to define the request parameter type and response data type of Method. Types.sol is a data type Library, which contains all data types of solidity.
methods
is used to store the method name array of each request type.
instructions
is used to store method instructions
options
function will return the request method type supported by the component.
setMethod
is used to set the request parameter type and response data type of the method.
getMethods
returns the response method names according to the request type.
getMethodReqAndRes
is used to obtain the request parameter type and response value type of the method based on the method name.
getMethodInstruction
is used to query the usage of method.
get
, post
, and put
.
options
options
to obtain supported request method types.getMethods
getMethods
to obtain the request method name.getMethodInstruction
getMethodInstruction
to obtain the request method instruction.getMethodReqAndRes
getMethodReqAndRes
to obtain the request parameter data type and response value data type.Encode
get
, post
, and put
.Decode