-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update web API, general fixes and improvements
- Loading branch information
Showing
11 changed files
with
125 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use actix_msgpack::MsgPackResponseBuilder; | ||
use actix_web::{ | ||
get, | ||
web::{Data, Query}, | ||
HttpResponse, Responder, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
use std::sync::Arc; | ||
|
||
use crate::core::{snapshot::Snapshot, Core}; | ||
|
||
#[derive(Deserialize, Debug)] | ||
#[serde(rename_all = "camelCase")] | ||
struct Request { | ||
client_id: u32, | ||
} | ||
|
||
#[derive(Serialize)] | ||
struct Response(Snapshot); | ||
|
||
#[get("/readAll")] | ||
async fn main(request: Query<Request>, core: Data<Arc<Core>>) -> impl Responder { | ||
if !core.queue().is_subscribed(request.client_id) { | ||
return HttpResponse::Unauthorized().body("Not subscribed"); | ||
} | ||
|
||
HttpResponse::Ok().msgpack(core.snapshot()) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use actix_web::{ | ||
get, | ||
web::{Data, Query}, | ||
HttpResponse, Responder, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
use std::sync::Arc; | ||
|
||
use crate::core::{snapshot::Snapshot, Core}; | ||
|
||
#[derive(Deserialize, Debug)] | ||
#[serde(rename_all = "camelCase")] | ||
struct Request { | ||
client_id: u32, | ||
snapshot: Snapshot, | ||
} | ||
|
||
#[derive(Serialize)] | ||
struct Response(Snapshot); | ||
|
||
#[get("/writeAll")] | ||
async fn main(request: Query<Request>, core: Data<Arc<Core>>) -> impl Responder { | ||
if !core.queue().is_subscribed(request.client_id) { | ||
return HttpResponse::Unauthorized().body("Not subscribed"); | ||
} | ||
|
||
core.processor().write_all(request.snapshot.clone()); | ||
|
||
HttpResponse::Ok().body("Written all changes successfully") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters