pub struct HttpExtensionConfig {
pub route_prefix: String,
pub auto_detect: bool,
pub default_priority: Priority,
pub max_streams_per_client: usize,
pub session_timeout: Duration,
pub allowed_origins: Vec<String>,
}Expand description
Configuration for PJS extension
Fields§
§route_prefix: StringRoute prefix for PJS endpoints (default: “/pjs”)
auto_detect: boolEnable automatic PJS detection based on Accept header
default_priority: PriorityDefault priority for streaming
max_streams_per_client: usizeMaximum concurrent streams per client
session_timeout: DurationSession timeout
allowed_origins: Vec<String>Origins allowed to receive Access-Control-Allow-Origin on the PJS
routes mounted by PjsExtension::extend_router (including the SSE
stream endpoint), validated with the same rules as
super::axum_adapter::HttpServerConfig::allowed_origins.
§Security
Defaults to vec![] — same-origin only, no Access-Control-Allow-Origin
header is added at all. PjsExtension is meant to bolt onto an
arbitrary existing router, so it must not weaken that router’s
cross-origin exposure unless the operator explicitly opts in here
(CWE-942): earlier versions unconditionally emitted a hardcoded
Access-Control-Allow-Origin: * on the SSE endpoint regardless of
the mounting application’s own CORS policy.
Set this to the origin(s) a cross-origin consumer runs on — e.g.
pjs-js-client’s EventSource-based SSE transport — to opt back
into cross-origin access with a validated allowlist instead of an
unconditional wildcard. ["*"] allows any origin; mixing "*" with
explicit origins is invalid and falls back to no CORS layer at all
(logged) rather than panicking. Origins are matched against the
request’s Origin header by case-sensitive byte equality — write
them in lowercase.
§Examples
use pjson_rs::infrastructure::http::HttpExtensionConfig;
let config = HttpExtensionConfig {
allowed_origins: vec!["https://app.example.com".to_string()],
..Default::default()
};
assert_eq!(config.allowed_origins.len(), 1);Trait Implementations§
Source§impl Clone for HttpExtensionConfig
impl Clone for HttpExtensionConfig
Source§fn clone(&self) -> HttpExtensionConfig
fn clone(&self) -> HttpExtensionConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HttpExtensionConfig
impl Debug for HttpExtensionConfig
Auto Trait Implementations§
impl Freeze for HttpExtensionConfig
impl RefUnwindSafe for HttpExtensionConfig
impl Send for HttpExtensionConfig
impl Sync for HttpExtensionConfig
impl Unpin for HttpExtensionConfig
impl UnsafeUnpin for HttpExtensionConfig
impl UnwindSafe for HttpExtensionConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more