fermyon / enterprise-architectures-and-patterns

Collection of Enterprise Architectures & Patterns built with Spin and WebAssembly
50 stars 12 forks source link

build_with_cors perhaps needs updating? #12

Closed tpmccallum closed 5 months ago

tpmccallum commented 5 months ago

Hi Thanks for this repo. Really useful I am compiling a Rust application that uses CORS.

I am getting the following error when using the build_with_cors function:

 .build_with_cors(&req, &load_cors_config()))
    |          ^^^^^^^^^^^^^^^ ----  ------------------- an argument of type `std::string::String` is missing
    |                          |
    |                          expected `&Method`, found `&Request`

It seems to want 3 arguments:

.build_with_cors(/* &spin_sdk::http::Method */, /* std::string::String */, &load_cors_config()))

Ref: https://github.com/fermyon/enterprise-architectures-and-patterns/blob/main/cors-rust/src/lib.rs#L57

tpmccallum commented 5 months ago

I am using spin-contrib-http = "0.0.7" and the example's Cargo.toml is using spin-contrib-http = "0.0.5" - I will downgrade for the time being.

ThorstenHans commented 5 months ago

@tpmccallum good catch. I've updated the sample to latest 0.0.8 (which I released earlier today).

I also updated the docs for this sample to illustrate how one could set allowed CORS origins using the Environment Variable Provider.