#[derive(Debug, Clone)]
pub struct HttpInboundAdapterSpec {
id: Option<String>,
host: String,
port: u16,
path: String,
methods: Vec<String>,
request_channel: String,
reply_channel: Option<String>,
}
impl HttpInboundAdapterSpec {
pub fn new<H: Into<String>, P: Into<String>, RC: Into<String>>(
host: H,
port: u16,
path: P,
methods: Vec<String>,
request_channel: RC,
) -> Self {
Self {
id: None,
host: host.into(),
port,
path: path.into(),
methods,
request_channel: request_channel.into(),
reply_channel: None,
}
}
pub fn with_id<ID: Into<String>, H: Into<String>, P: Into<String>, RC: Into<String>>(
id: ID,
host: H,
port: u16,
path: P,
methods: Vec<String>,
request_channel: RC,
) -> Self {
Self {
id: Some(id.into()),
host: host.into(),
port,
path: path.into(),
methods,
request_channel: request_channel.into(),
reply_channel: None,
}
}
pub fn with_reply<H: Into<String>, P: Into<String>, RC: Into<String>, R: Into<String>>(
host: H,
port: u16,
path: P,
methods: Vec<String>,
request_channel: RC,
reply_channel: R,
) -> Self {
Self {
id: None,
host: host.into(),
port,
path: path.into(),
methods,
request_channel: request_channel.into(),
reply_channel: Some(reply_channel.into()),
}
}
pub fn with_id_reply<
ID: Into<String>,
H: Into<String>,
P: Into<String>,
RC: Into<String>,
R: Into<String>,
>(
id: ID,
host: H,
port: u16,
path: P,
methods: Vec<String>,
request_channel: RC,
reply_channel: R,
) -> Self {
Self {
id: Some(id.into()),
host: host.into(),
port,
path: path.into(),
methods,
request_channel: request_channel.into(),
reply_channel: Some(reply_channel.into()),
}
}
pub fn id(&self) -> Option<&str> {
self.id.as_deref()
}
pub fn host(&self) -> &str {
&self.host
}
pub fn port(&self) -> u16 {
self.port
}
pub fn path(&self) -> &str {
&self.path
}
pub fn methods(&self) -> &[String] {
&self.methods
}
pub fn request_channel(&self) -> &str {
&self.request_channel
}
pub fn reply_channel(&self) -> Option<&str> {
self.reply_channel.as_deref()
}
pub fn set_id(&mut self, id: String) {
self.id = Some(id);
}
}