mirror of
https://github.com/fafhrd91/actix-web
synced 2025-08-27 23:45:53 +02:00
use server settings for scheme and host values
This commit is contained in:
@@ -8,6 +8,7 @@ use regex::{Regex, RegexSet};
|
||||
use error::UrlGenerationError;
|
||||
use resource::Resource;
|
||||
use httprequest::HttpRequest;
|
||||
use server::ServerSettings;
|
||||
|
||||
|
||||
/// Interface for application router.
|
||||
@@ -19,6 +20,7 @@ struct Inner<S> {
|
||||
named: HashMap<String, (Pattern, bool)>,
|
||||
patterns: Vec<Pattern>,
|
||||
resources: Vec<Resource<S>>,
|
||||
srv: ServerSettings,
|
||||
}
|
||||
|
||||
impl<S> Router<S> {
|
||||
@@ -49,7 +51,12 @@ impl<S> Router<S> {
|
||||
regset: RegexSet::new(&paths).unwrap(),
|
||||
named: named,
|
||||
patterns: patterns,
|
||||
resources: resources }))
|
||||
resources: resources,
|
||||
srv: ServerSettings::default() }))
|
||||
}
|
||||
|
||||
pub(crate) fn set_server_settings(&mut self, settings: ServerSettings) {
|
||||
Rc::get_mut(&mut self.0).unwrap().srv = settings;
|
||||
}
|
||||
|
||||
/// Router prefix
|
||||
@@ -58,6 +65,12 @@ impl<S> Router<S> {
|
||||
&self.0.prefix
|
||||
}
|
||||
|
||||
/// Server settings
|
||||
#[inline]
|
||||
pub fn server_settings(&self) -> &ServerSettings {
|
||||
&self.0.srv
|
||||
}
|
||||
|
||||
/// Query for matched resource
|
||||
pub fn recognize(&self, req: &mut HttpRequest<S>) -> Option<&Resource<S>> {
|
||||
let mut idx = None;
|
||||
|
Reference in New Issue
Block a user