Skip to content

warcade/api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webarcade-api

Plugin API for WebArcade - Build native desktop plugins with Rust.

Installation

[dependencies]
webarcade-api = "0.1"

# Enable bridge feature for HTTP route handlers
webarcade-api = { version = "0.1", features = ["bridge"] }

Quick Start

use api::{Plugin, PluginMetadata};

pub struct MyPlugin;

impl Plugin for MyPlugin {
    fn metadata(&self) -> PluginMetadata {
        PluginMetadata {
            id: "my-plugin".into(),
            name: "My Plugin".into(),
            version: "1.0.0".into(),
            description: "A WebArcade plugin".into(),
            author: "You".into(),
            dependencies: vec![],
        }
    }
}

HTTP Route Handlers

Enable the bridge feature to create HTTP route handlers:

use api::{HttpRequest, HttpResponse, json, json_response};

pub async fn handle_hello(_req: HttpRequest) -> HttpResponse {
    json_response(&json!({
        "message": "Hello from Rust!"
    }))
}

Define routes in your plugin's Cargo.toml:

[routes]
"GET /hello" = "handle_hello"
"POST /data" = "handle_data"

Features

  • bridge - Enable HTTP bridge functionality (tokio runtime, HTTP types). Only needed for plugins that define routes.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages