Open itowlson opened 1 year ago
https://github.com/fermyon/spin/pull/1977
use spin_sdk::http::Request;
let resp: Response = spin_sdk::http::send(Request::get(
"https://random-data-api.fermyon.app/animals/json",
)).await?;
@lann I might be misunderstanding - we already had builders for Request
, although your new ones are nicer for sure - this issue was specifically about OutgoingRequest
. Are you saying to no longer use OutgoingRequest
? (My specific interest was streaming request bodies.) Or is the idea that we could construct a Request
with the friendly builder and then .into()
it to get an OutgoingRequest
?
Ah no the linked PR doesn't help with streaming request bodies. The example you linked just streams the response body, and I think you can mix-n-match a non-streaming Request
with a streaming IncomingResponse
.
I'm not explaining myself very well I fear.
OutgoingRequest
.OutgoingRequest
is not terribly friendly.I linked the example to try illustrate the third item not the first one, and was trying to clarify if fermyon/spin#1977 helps with said third one. My mention of streaming was only to explain why I (thought I) needed an OutgoingRequest
rather than a Request
.
Sorry for the confusion.
Per https://github.com/fermyon/spin/blob/b45feb8e91afe5625a2de19e1904eec10ebbc936/examples/wasi-http-rust-streaming-outgoing-body/src/lib.rs#L99:
Could we add a constructor or builder that takes a URL, and maybe a Method instead of &Method? It feels a bit unwieldy right now (though users can always create their own wrappers).