Skip to content

Commit

Permalink
Reexport HTTP status code to avoid http crate related conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
abdolence committed Dec 8, 2023
1 parent 9e1a232 commit 5eec8c1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions docs/src/events-api-axum.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ fn test_error_handler(
err: Box<dyn std::error::Error + Send + Sync>,
_client: Arc<SlackHyperClient>,
_states: SlackClientEventsUserState,
) -> http::StatusCode {
) -> HttpStatusCode {
println!("{:#?}", err);
// Defines what we return Slack server
http::StatusCode::BAD_REQUEST
HttpStatusCode::BAD_REQUEST
}
async fn test_server() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
Expand Down
4 changes: 2 additions & 2 deletions examples/axum_events_api_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ fn test_error_handler(
err: Box<dyn std::error::Error + Send + Sync>,
_client: Arc<SlackHyperClient>,
_states: SlackClientEventsUserState,
) -> http::StatusCode {
) -> HttpStatusCode {
println!("{:#?}", err);

// Defines what we return Slack server
http::StatusCode::BAD_REQUEST
HttpStatusCode::BAD_REQUEST
}

async fn test_server() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
Expand Down
4 changes: 2 additions & 2 deletions examples/events_api_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ fn test_error_handler(
err: Box<dyn std::error::Error + Send + Sync>,
_client: Arc<SlackHyperClient>,
_states: SlackClientEventsUserState,
) -> http::StatusCode {
) -> HttpStatusCode {
println!("{:#?}", err);

// Defines what we return Slack server
http::StatusCode::BAD_REQUEST
HttpStatusCode::BAD_REQUEST
}

#[derive(Debug)]
Expand Down
4 changes: 2 additions & 2 deletions examples/socket_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ fn test_error_handler(
err: Box<dyn std::error::Error + Send + Sync>,
_client: Arc<SlackHyperClient>,
_states: SlackClientEventsUserState,
) -> http::StatusCode {
) -> HttpStatusCode {
println!("{:#?}", err);

// This return value should be OK if we want to return successful ack to the Slack server using Web-sockets
// https://api.slack.com/apis/connections/socket-implement#acknowledge
// so that Slack knows whether to retry
http::StatusCode::OK
HttpStatusCode::OK
}

async fn test_client_with_socket_mode() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
Expand Down
4 changes: 2 additions & 2 deletions examples/state_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ fn test_error_handler(
err: Box<dyn std::error::Error + Send + Sync>,
_client: Arc<SlackHyperClient>,
_states: SlackClientEventsUserState,
) -> http::StatusCode {
) -> HttpStatusCode {
println!("{:#?}", err);

// This return value should be OK if we want to return successful ack to the Slack server using Web-sockets
// https://api.slack.com/apis/connections/socket-implement#acknowledge
// so that Slack knows whether to retry
http::StatusCode::OK
HttpStatusCode::OK
}

async fn test_client_with_socket_mode() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
Expand Down
4 changes: 3 additions & 1 deletion src/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use url::Url;

type UserStatesMap = HashMap<TypeId, Box<dyn Any + Send + Sync + 'static>>;

pub type HttpStatusCode = http::StatusCode;

pub struct SlackClientEventsListenerEnvironment<SCHC>
where
SCHC: SlackClientHttpConnector + Send + Sync,
Expand Down Expand Up @@ -98,7 +100,7 @@ pub type ErrorHandler<SCHC> = fn(
Box<dyn std::error::Error + Send + Sync + 'static>,
Arc<SlackClient<SCHC>>,
SlackClientEventsUserState,
) -> http::StatusCode;
) -> HttpStatusCode;

#[derive(Debug, PartialEq, Eq, Clone, Builder)]
pub struct SlackCommandEventsListenerConfig {
Expand Down

0 comments on commit 5eec8c1

Please sign in to comment.