Remote fetching of data
Pre-release
Pre-release
tpmccallum
released this
15 Jul 02:02
·
336 commits
to master
since this release
This release allows the caller to specify a SSVM_Fetch
parameter that will:
GET
and return the data from the URL providedPOST
and return the data from the request object provided
This allows the caller to deal with large files without having to upload/download them. The GET and POST activities take place on the server side. The client stays light.
Examples
SSVM_Fetch in the request body (passes the response from the request and ignores any peripheral data in the body)
curl --location --request POST 'https://rpc.ssvm.secondstate.io:8081/api/run/1/say' \
--header 'SSVM_Usage_Key: 83f02dd3-6440-482f-983f-78127ed6f943' \
--header 'Content-Type: application/json' \
--data-raw '{
"SSVM_Fetch": {
"body": "body",
"hostname": "rpc.ssvm.secondstate.io",
"path": "/api/run/1/say",
"method": "POST",
"port": 8081,
"headers": {
"Content-Type": "text/plain",
"SSVM_Usage_Key": "83f02dd3-6440-482f-983f-78127ed6f943"
}
},
"function_params": [1, 2]
}'
Returns
hello hello "body"
SSVM_Fetch in the request head (overrides body and any peripheral data)
curl --location --request POST 'https://rpc.ssvm.secondstate.io:8081/api/run/1/say' \
--header 'SSVM_Usage_Key: 83f02dd3-6440-482f-983f-78127ed6f943' \
--header 'SSVM_Fetch: {"body": "header","hostname": "rpc.ssvm.secondstate.io","path": "/api/run/1/say","method": "POST","port": 8081,"headers": {"Content-Type": "text/plain","SSVM_Usage_Key": "83f02dd3-6440-482f-983f-78127ed6f943"}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"SSVM_Fetch": {
"body": "body",
"hostname": "rpc.ssvm.secondstate.io",
"path": "/api/run/1/say",
"method": "POST",
"port": 8081,
"headers": {
"Content-Type": "text/plain",
"SSVM_Usage_Key": "83f02dd3-6440-482f-983f-78127ed6f943"
}
},
"function_params": [1, 2]
}'
Returns
hello hello "header"
SSVM_Fetch in the request body; providing only a URL
curl --location --request POST 'https://rpc.ssvm.secondstate.io:8081/api/run/1/say' \
--header 'SSVM_Usage_Key: 83f02dd3-6440-482f-983f-78127ed6f943' \
--header 'Content-Type: application/json' \
--data-raw '{
"SSVM_Fetch": "https://raw.githubusercontent.com/tpmccallum/test_endpoint2/master/tim.txt",
"function_params": [1, 2]
}'
Returns
hello Tim
SSVM_Fetch in the request header; providing only a URL
curl --location --request POST 'https://rpc.ssvm.secondstate.io:8081/api/run/1/say' \
--header 'SSVM_Usage_Key: 83f02dd3-6440-482f-983f-78127ed6f943' \
--header 'SSVM_Fetch: https://raw.githubusercontent.com/tpmccallum/test_endpoint2/master/tim2.txt' \
--header 'Content-Type: application/json' \
--data-raw '{
"SSVM_Fetch": "https://raw.githubusercontent.com/tpmccallum/test_endpoint2/master/tim.txt"
}'
Returns
hello Tim2
Note:
SSVM_Fetch
overrides other data provided and only passes the response from the fetch-able endpoint to the function being called- Header overrides body