-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented basic support for prelogin and notification negotiation
- Loading branch information
1 parent
c91f80c
commit 8d1ee85
Showing
5 changed files
with
63 additions
and
0 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
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 |
---|---|---|
|
@@ -25,6 +25,7 @@ pub fn routes() -> Vec<Route> { | |
delete_account, | ||
revision_date, | ||
password_hint, | ||
prelogin, | ||
|
||
sync, | ||
|
||
|
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,31 @@ | ||
use rocket::Route; | ||
use rocket_contrib::Json; | ||
|
||
use db::DbConn; | ||
use api::JsonResult; | ||
use auth::Headers; | ||
|
||
pub fn routes() -> Vec<Route> { | ||
routes![negotiate] | ||
} | ||
|
||
#[post("/hub/negotiate")] | ||
fn negotiate(_headers: Headers, _conn: DbConn) -> JsonResult { | ||
use data_encoding::BASE64URL; | ||
use crypto; | ||
|
||
// Store this in db? | ||
let conn_id = BASE64URL.encode(&crypto::get_random(vec![0u8; 16])); | ||
|
||
// TODO: Implement transports | ||
// Rocket WS support: https://github.com/SergioBenitez/Rocket/issues/90 | ||
// Rocket SSE support: https://github.com/SergioBenitez/Rocket/issues/33 | ||
Ok(Json(json!({ | ||
"connectionId": conn_id, | ||
"availableTransports":[ | ||
// {"transport":"WebSockets", "transferFormats":["Text","Binary"]}, | ||
// {"transport":"ServerSentEvents", "transferFormats":["Text"]}, | ||
// {"transport":"LongPolling", "transferFormats":["Text","Binary"]} | ||
] | ||
}))) | ||
} |
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