-
Notifications
You must be signed in to change notification settings - Fork 3
Now
Sleeyax edited this page Apr 5, 2020
·
3 revisions
This SDK supports now.sh deployments out of the box. You do not need any additional dependencies and the process is fairly simple.
To follow along, we're assuming you have the following project structure:
src
- main.rs
Cargo.lock
Cargo.toml
Create src/serverless.rs
with the following content:
use stremio_addon_sdk::server::ServerOptions;
use stremio_addon_sdk::server::serve_serverless;
use stremio_addon_sdk::export::serverless::now::*;
fn handler(req: Request) -> Result<impl IntoResponse, NowError> {
let manifest: Manifest = // your manifest here;
let interface: BuilderWithHandlers = // your builder build here;
let options: ServerOptions = // your HTTP server options here;
// serve now.sh lambda
serve_serverless(req, build, options)
}
Add a now.json
file to your project root folder:
{
"version": 2,
"name": "my-awesome-addon"
"builds": [
{
"src": "src/serverless.rs",
"use": "now-rust",
"config": {
"functions": {
"Cargo.toml": {
"runtime": "now-rust"
}
}
}
}
],
"routes": [
{
"src": "/.*",
"dest": "/src/serverless.rs"
}
]
}
Enter now
in your terminal and watch the magic happen!