mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Move API to /api, in preparation for web interface in /
This commit is contained in:
parent
fff8741817
commit
1dc69d81dc
1 changed files with 8 additions and 4 deletions
|
|
@ -70,6 +70,10 @@ impl Server {
|
||||||
fn handle_request(&self, request: &Request) -> Response {
|
fn handle_request(&self, request: &Request) -> Response {
|
||||||
router!(request,
|
router!(request,
|
||||||
(GET) (/) => {
|
(GET) (/) => {
|
||||||
|
Response::text("Rojo up and running!")
|
||||||
|
},
|
||||||
|
|
||||||
|
(GET) (/api/rojo) => {
|
||||||
// Get a summary of information about the server.
|
// Get a summary of information about the server.
|
||||||
|
|
||||||
let mut partitions = HashMap::new();
|
let mut partitions = HashMap::new();
|
||||||
|
|
@ -86,7 +90,7 @@ impl Server {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
(GET) (/subscribe/{ cursor: i32 }) => {
|
(GET) (/api/subscribe/{ cursor: i32 }) => {
|
||||||
// Retrieve any messages past the given cursor index, and if
|
// Retrieve any messages past the given cursor index, and if
|
||||||
// there weren't any, subscribe to receive any new messages.
|
// there weren't any, subscribe to receive any new messages.
|
||||||
|
|
||||||
|
|
@ -138,7 +142,7 @@ impl Server {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
(GET) (/read_all) => {
|
(GET) (/api/read_all) => {
|
||||||
let rbx_session = self.config.rbx_session.read().unwrap();
|
let rbx_session = self.config.rbx_session.read().unwrap();
|
||||||
|
|
||||||
let message_cursor = {
|
let message_cursor = {
|
||||||
|
|
@ -153,7 +157,7 @@ impl Server {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
(POST) (/read) => {
|
(POST) (/api/read) => {
|
||||||
let requested_ids = match read_json::<Vec<Id>>(request) {
|
let requested_ids = match read_json::<Vec<Id>>(request) {
|
||||||
Some(body) => body,
|
Some(body) => body,
|
||||||
None => return rouille::Response::text("Malformed JSON").with_status_code(400),
|
None => return rouille::Response::text("Malformed JSON").with_status_code(400),
|
||||||
|
|
@ -184,7 +188,7 @@ impl Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Start the Rojo web server and park our current thread.
|
/// Start the Rojo web server, taking over the current thread.
|
||||||
#[allow(unreachable_code)]
|
#[allow(unreachable_code)]
|
||||||
pub fn start(config: WebConfig) {
|
pub fn start(config: WebConfig) {
|
||||||
let address = format!("localhost:{}", config.port);
|
let address = format!("localhost:{}", config.port);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue