mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-23 22:25:26 +00:00
DESIGN doc, stub out /write endpoint
This commit is contained in:
20
DESIGN.md
Normal file
20
DESIGN.md
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Rojo Design
|
||||||
|
This is a super rough draft that I'm trying to use to lay out of my thoughts.
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
### POST `/read`
|
||||||
|
Accepts a `Vec<Route>` of items to read.
|
||||||
|
|
||||||
|
Returns `Vec<Option<RbxItem>>`, in the same order as the request.
|
||||||
|
|
||||||
|
### POST `/write`
|
||||||
|
Accepts a `Vec<{ Route, RbxItem }>` of items to write.
|
||||||
|
|
||||||
|
I imagine that the `Name` attribute of the top-level `RbxItem` would be ignored in favor of the route name?
|
||||||
|
|
||||||
|
## CLI
|
||||||
|
|
||||||
|
### Transform Plugins
|
||||||
|
|
||||||
|
## Roblox Studio Plugin
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct RbxItem {
|
pub struct RbxItem {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
@@ -9,7 +9,7 @@ pub struct RbxItem {
|
|||||||
pub properties: HashMap<String, RbxValue>,
|
pub properties: HashMap<String, RbxValue>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase", tag = "type")]
|
#[serde(rename_all = "camelCase", tag = "type")]
|
||||||
pub enum RbxValue {
|
pub enum RbxValue {
|
||||||
String {
|
String {
|
||||||
|
|||||||
14
src/web.rs
14
src/web.rs
@@ -40,6 +40,13 @@ struct ChangesResult<'a> {
|
|||||||
current_time: f64,
|
current_time: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
struct WriteSpecifier {
|
||||||
|
route: String,
|
||||||
|
item: RbxItem,
|
||||||
|
}
|
||||||
|
|
||||||
fn json<T: serde::Serialize>(value: T) -> rouille::Response {
|
fn json<T: serde::Serialize>(value: T) -> rouille::Response {
|
||||||
let data = serde_json::to_string(&value).unwrap();
|
let data = serde_json::to_string(&value).unwrap();
|
||||||
rouille::Response::from_data("application/json", data)
|
rouille::Response::from_data("application/json", data)
|
||||||
@@ -181,6 +188,13 @@ pub fn start(config: Config, project: Project, vfs: Arc<Mutex<Vfs>>) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
(POST) (/write) => {
|
(POST) (/write) => {
|
||||||
|
let _plugin_chain = PLUGIN_CHAIN.lock().unwrap();
|
||||||
|
|
||||||
|
let _write_request: Vec<WriteSpecifier> = match read_json(&request) {
|
||||||
|
Some(v) => v,
|
||||||
|
None => return rouille::Response::empty_400(),
|
||||||
|
};
|
||||||
|
|
||||||
rouille::Response::empty_404()
|
rouille::Response::empty_404()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user