-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 241-implement-the-basic-message-protocol
merging main
- Loading branch information
Showing
41 changed files
with
610 additions
and
647 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: CD | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Rust | ||
uses: actions/setup-rust@v1 | ||
with: | ||
rust-version: stable | ||
|
||
# Deploy to AWS EC2 Or another instance |
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
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
2 changes: 1 addition & 1 deletion
2
crates/web-plugins/didcomm-messaging/did-utils/src/methods/peer/util.rs
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
36 changes: 20 additions & 16 deletions
36
crates/web-plugins/didcomm-messaging/protocols/forward/src/error.rs
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 |
---|---|---|
@@ -1,25 +1,29 @@ | ||
use axum::Json; | ||
use serde_json::{json, Value}; | ||
use axum::{response::IntoResponse, Json}; | ||
use hyper::StatusCode; | ||
use thiserror::Error; | ||
|
||
#[derive(Debug, Error)] | ||
pub enum RoutingError { | ||
pub enum ForwardError { | ||
#[error("message body is malformed")] | ||
MalformedBody, | ||
#[error("Repository not set")] | ||
RepostitoryError | ||
} | ||
impl RoutingError { | ||
/// Converts the error to an axum JSON representation. | ||
pub fn json(&self) -> Json<Value> { | ||
Json(json!({ | ||
"error": self.to_string() | ||
})) | ||
} | ||
#[error("Uncoordinated sender")] | ||
UncoordinatedSender, | ||
#[error("Internal server error")] | ||
InternalServerError, | ||
} | ||
|
||
impl From<RoutingError> for Json<Value> { | ||
fn from(error: RoutingError) -> Self { | ||
error.json() | ||
impl IntoResponse for ForwardError { | ||
fn into_response(self) -> axum::response::Response { | ||
let status_code = match self { | ||
ForwardError::MalformedBody => StatusCode::BAD_REQUEST, | ||
ForwardError::UncoordinatedSender => StatusCode::UNAUTHORIZED, | ||
ForwardError::InternalServerError => StatusCode::INTERNAL_SERVER_ERROR, | ||
}; | ||
|
||
let body = Json(serde_json::json!({ | ||
"error": self.to_string(), | ||
})); | ||
|
||
(status_code, body).into_response() | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
crates/web-plugins/didcomm-messaging/protocols/forward/src/lib.rs
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
mod error; | ||
|
||
pub mod web; | ||
|
||
// Re-exports | ||
pub use error::ForwardError; |
10 changes: 5 additions & 5 deletions
10
crates/web-plugins/didcomm-messaging/protocols/forward/src/web/handler.rs
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
use super::routing::handler; | ||
use axum::response::Response; | ||
use crate::{web::routing::handler, ForwardError}; | ||
use didcomm::Message; | ||
use shared::state::AppState; | ||
use std::sync::Arc; | ||
|
||
/// Mediator receives forwarded messages, extract the next field in the message body, and the attachments in the message | ||
/// then stores the attachment with the next field as key for pickup | ||
pub async fn mediator_forward_process( | ||
state: &AppState, | ||
state: Arc<AppState>, | ||
payload: Message, | ||
) -> Result<Message, Response> { | ||
let result = handler(state, payload).await.unwrap(); | ||
) -> Result<Option<Message>, ForwardError> { | ||
let result = handler(state.clone(), payload).await.unwrap(); | ||
Ok(result) | ||
} |
Oops, something went wrong.