mirror of
https://github.com/System-End/slack-morphism-rust.git
synced 2026-04-19 18:35:19 +00:00
feat: Cargo config features for TLS (#342)
* feat: SlackMessageAttachmentId * feat: Cargo features for TLS
This commit is contained in:
parent
c0d9446f43
commit
48a129f704
7 changed files with 28 additions and 17 deletions
21
Cargo.toml
21
Cargo.toml
|
|
@ -23,13 +23,16 @@ path = "src/lib.rs"
|
|||
[features]
|
||||
default = []
|
||||
signature-verifier = ["dep:sha2", "dep:subtle", "dep:hmac"]
|
||||
hyper = ["dep:tokio", "dep:http-body-util", "dep:hyper", "dep:hyper-rustls", "dep:hyper-util", "dep:tokio-stream", "dep:tokio-tungstenite", "dep:signal-hook", "dep:signal-hook-tokio", "signature-verifier"]
|
||||
axum = ["hyper", "dep:axum", "dep:tower"]
|
||||
hyper-base = ["dep:tokio", "dep:http-body-util", "dep:hyper", "dep:hyper-rustls", "dep:hyper-util", "dep:tokio-stream", "dep:tokio-tungstenite", "dep:signal-hook", "dep:signal-hook-tokio", "signature-verifier"]
|
||||
axum-base = ["hyper-base", "dep:axum", "dep:tower"]
|
||||
rustls-native-certs = ["tokio-tungstenite/rustls-native-certs", "hyper-rustls/rustls-native-certs", "hyper-rustls/ring"]
|
||||
hyper = ["hyper-base", "rustls-native-certs"]
|
||||
axum = ["axum-base", "hyper-base", "rustls-native-certs"]
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde = { version = "1.0", features = ["derive"], default-features = false }
|
||||
serde_json = "1.0"
|
||||
serde_with = { version = "3.8", features = ["json"] }
|
||||
serde_with = { version = "3.8", features = ["json", "macros"], default-features = false }
|
||||
rvstruct = "0.3"
|
||||
rsb_derive = "0.5"
|
||||
futures = "0.3"
|
||||
|
|
@ -49,12 +52,12 @@ mime_guess = "2"
|
|||
chrono = { version = "0.4", default-features = false, features = ["clock", "std", "serde"] }
|
||||
url = { version = "2.5", features = ["serde"] }
|
||||
http-body-util = { version = "0.1", optional = true }
|
||||
hyper = { version = "1.3", features = ["http2", "server", "client"], optional = true }
|
||||
hyper-util = { version = "0.1", features = ["client", "client-legacy", "server"], optional = true }
|
||||
tokio = { version = "1", features = ["bytes", "rt-multi-thread", "signal", "tracing"], optional = true }
|
||||
hyper = { version = "1.3", features = ["http2", "server", "client"], default-features = false, optional = true }
|
||||
hyper-util = { version = "0.1", features = ["client", "client-legacy", "server", "tokio"], default-features = false, optional = true }
|
||||
tokio = { version = "1", features = ["bytes", "rt-multi-thread", "signal", "tracing"], default-features = false, optional = true }
|
||||
tokio-stream = { version = "0.1", optional = true }
|
||||
hyper-rustls = { version = "0.27", features = ["rustls-native-certs", "http2"], optional = true }
|
||||
tokio-tungstenite = { version = "0.28.0", features = ["rustls-tls-native-roots"], optional = true }
|
||||
hyper-rustls = { version = "0.27", features = ["http2", "native-tokio"], default-features = false, optional = true }
|
||||
tokio-tungstenite = { version = "0.28.0", features = [], optional = true }
|
||||
axum = { version = "0.8", optional = true }
|
||||
tower = { version = "0.5", optional = true }
|
||||
sha2 = { version = "0.10", optional = true }
|
||||
|
|
|
|||
|
|
@ -20,3 +20,7 @@ Includes also all type/models definitions that used for Slack Web/Events APIs.
|
|||
This library provided the following features:
|
||||
- `hyper`: Slack client support/binding for Hyper/Tokio/Tungstenite.
|
||||
- `axum`: Slack client support/binding for [axum framework](https://github.com/tokio-rs/axum) support.
|
||||
|
||||
### TLS-related configuration features
|
||||
By default, `hyper` and `axum` features use `rustls-native-certs` and `hyper-rustls/ring` setup for TLS configuration,
|
||||
but you can switch off default-features and use `hyper-base` and `axum-base` features and have your own TLS configuration.
|
||||
|
|
|
|||
|
|
@ -105,10 +105,10 @@ pub mod socket_mode;
|
|||
pub mod multipart_form;
|
||||
mod token;
|
||||
|
||||
#[cfg(feature = "hyper")]
|
||||
#[cfg(feature = "hyper-base")]
|
||||
pub mod hyper_tokio;
|
||||
|
||||
#[cfg(feature = "axum")]
|
||||
#[cfg(feature = "axum-base")]
|
||||
pub mod axum_support;
|
||||
|
||||
pub mod prelude;
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ pub struct SlackInteractionActionMessageContainer {
|
|||
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
|
||||
pub struct SlackInteractionActionMessageAttachmentContainer {
|
||||
pub message_ts: SlackTs,
|
||||
pub attachment_id: i64,
|
||||
pub attachment_id: SlackMessageAttachmentId,
|
||||
pub channel_id: Option<SlackChannelId>,
|
||||
pub is_ephemeral: Option<bool>,
|
||||
pub is_app_unfurl: Option<bool>,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ use crate::blocks::*;
|
|||
use crate::events::SlackMessageEventType;
|
||||
use crate::*;
|
||||
use rsb_derive::Builder;
|
||||
use rvstruct::ValueStruct;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
|
||||
|
|
@ -115,12 +116,15 @@ pub enum SlackMessageResponseType {
|
|||
Ephemeral,
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Hash, Clone, Serialize, Deserialize, ValueStruct)]
|
||||
pub struct SlackMessageAttachmentId(i64);
|
||||
|
||||
// This model is not well typed since Slack message attachments are deprecated
|
||||
// Please avoid using this if you can
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
|
||||
pub struct SlackMessageAttachment {
|
||||
pub id: Option<i64>,
|
||||
pub id: Option<SlackMessageAttachmentId>,
|
||||
pub color: Option<String>,
|
||||
pub fallback: Option<String>,
|
||||
pub title: Option<String>,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ pub struct FileMultipartData<'a> {
|
|||
pub data: &'a [u8],
|
||||
}
|
||||
|
||||
#[cfg(feature = "hyper")]
|
||||
#[cfg(feature = "hyper-base")]
|
||||
pub fn generate_multipart_boundary() -> String {
|
||||
format!(
|
||||
"----WebKitFormBoundarySlackMorphismRust{}",
|
||||
|
|
@ -16,7 +16,7 @@ pub fn generate_multipart_boundary() -> String {
|
|||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "hyper")]
|
||||
#[cfg(feature = "hyper-base")]
|
||||
pub fn create_multipart_file_content<'p, PT, TS>(
|
||||
fields: &'p PT,
|
||||
multipart_boundary: &str,
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ pub use crate::models::blocks::*; // Slack Block Kit models
|
|||
pub use crate::models::events::*;
|
||||
pub use crate::models::*; // common Slack models like SlackUser, etc and macros // Slack Events Models
|
||||
|
||||
#[cfg(feature = "hyper")]
|
||||
#[cfg(feature = "hyper-base")]
|
||||
pub use crate::hyper_tokio::*;
|
||||
|
||||
#[cfg(feature = "axum")]
|
||||
#[cfg(feature = "axum-base")]
|
||||
pub use crate::axum_support::*;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue