fermyon / autobindle Goto Github PK
View Code? Open in Web Editor NEWA VS Code extension to smooth Bindle-based development workflows
License: Apache License 2.0
A VS Code extension to smooth Bindle-based development workflows
License: Apache License 2.0
Hello, I 'm currently testing spin with rust to develop a simple API REST. I searched in the documentation but i didn't find a way to used multiple endpoint's inside the same .rs. This work can be done by using multiple .rs of course, but I'm wondering if it's possible to define it without using a match.
My current work is like this:
fn hello(req: Request) -> Result {
println!("{:?}", req.headers());
match req.method() {
&Method::POST => {
Ok(http::Response::builder()
.status(200)
//.header("foo", "bar")
.body(Some("POST!\n".into()))?)
}
&Method::GET => {
Ok(http::Response::builder()
.status(200)
//.header("foo", "bar")
.body(Some("GET!\n".into()))?)
}
&Method::DELETE => {
Ok(http::Response::builder()
.status(200)
//.header("foo", "bar")
.body(Some("DELETE!\n".into()))?)
}
}
Ok(bad_request())
}
fn bad_request() -> Response {
http::Response::builder().status(400).into()
}
But what I want is something like this:
#[http_component]
fn hello_get(req: Request) -> Result {
println!("{:?}", req.headers());
Ok(http::Response::builder()
.status(200)
//.header("foo", "bar")
.body(Some("GET!\n".into()))?)
}
#[http_component]
fn hello_post(req: Request) -> Result {
println!("{:?}", req.headers());
Ok(http::Response::builder()
.status(200)
//.header("foo", "bar")
.body(Some("POST!\n".into()))?)
}
#[http_component]
fn hello_delete(req: Request) -> Result {
println!("{:?}", req.headers());
Ok(http::Response::builder()
.status(200)
//.header("foo", "bar")
.body(Some("DELETE!\n".into()))?)
}
Is this possible? How can I do it?
I get the following error trying to start Bindle in a new environment:
[2022-02-23 10:10:50.516] [exthost] [error] Canceled: Canceled
at Object.F [as canceled] (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:5:1172)
at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:97:9076
at Array.forEach (<anonymous>)
at i.dispose (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:97:9024)
at p.terminate (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:102:694)
at s (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:112:36409)
at Socket.<anonymous> (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:112:34061)
at Socket.emit (events.js:327:22)
at Pipe.<anonymous> (net.js:673:12) autobindle.stop {"value":"fermyon.autobindle","_lower":"fermyon.autobindle"}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.