Fixing compilation errors
This commit is contained in:
parent
13c25c5d49
commit
7516b737ee
@ -42,7 +42,7 @@ impl<T: WebApp> Endpoint for PageEndpoint<T> {
|
|||||||
Box::new(PageHandler {
|
Box::new(PageHandler {
|
||||||
app: self.app.clone(),
|
app: self.app.clone(),
|
||||||
prefix: prefix.to_owned(),
|
prefix: prefix.to_owned(),
|
||||||
prefix2: prefix.to_owned() + "/",
|
prefix_with_slash: prefix.to_owned() + "/",
|
||||||
path: None,
|
path: None,
|
||||||
write_pos: 0,
|
write_pos: 0,
|
||||||
})
|
})
|
||||||
@ -52,7 +52,7 @@ impl<T: WebApp> Endpoint for PageEndpoint<T> {
|
|||||||
struct PageHandler<T: WebApp + 'static> {
|
struct PageHandler<T: WebApp + 'static> {
|
||||||
app: Arc<T>,
|
app: Arc<T>,
|
||||||
prefix: String,
|
prefix: String,
|
||||||
prefix2: String,
|
prefix_with_slash: String,
|
||||||
path: Option<String>,
|
path: Option<String>,
|
||||||
write_pos: usize,
|
write_pos: usize,
|
||||||
}
|
}
|
||||||
@ -60,12 +60,11 @@ struct PageHandler<T: WebApp + 'static> {
|
|||||||
impl<T: WebApp + 'static> server::Handler<HttpStream> for PageHandler<T> {
|
impl<T: WebApp + 'static> server::Handler<HttpStream> for PageHandler<T> {
|
||||||
fn on_request(&mut self, req: server::Request) -> Next {
|
fn on_request(&mut self, req: server::Request) -> Next {
|
||||||
if let RequestUri::AbsolutePath(ref path) = *req.uri() {
|
if let RequestUri::AbsolutePath(ref path) = *req.uri() {
|
||||||
// Support index file
|
// Index file support
|
||||||
if path == &self.prefix || path == &self.prefix2 {
|
self.path = match path == &self.prefix || path == &self.prefix_with_slash {
|
||||||
self.path = Some("index.html".to_owned());
|
true => Some("index.html".to_owned()),
|
||||||
} else {
|
false => Some(path[self.prefix_with_slash.len()..].to_owned()),
|
||||||
self.path = Some(path[self.prefix2.len()..].to_owned());
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Next::write()
|
Next::write()
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,13 @@ use endpoint::Endpoint;
|
|||||||
pub fn rpc(handler: Arc<IoHandler>) -> Box<Endpoint> {
|
pub fn rpc(handler: Arc<IoHandler>) -> Box<Endpoint> {
|
||||||
Box::new(RpcEndpoint {
|
Box::new(RpcEndpoint {
|
||||||
handler: handler,
|
handler: handler,
|
||||||
cors_domain: AccessControlAllowOrigin::Null
|
cors_domain: Some(AccessControlAllowOrigin::Null)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RpcEndpoint {
|
struct RpcEndpoint {
|
||||||
handler: Arc<IoHandler>,
|
handler: Arc<IoHandler>,
|
||||||
cors_domain: AccessControlAllowOrigin,
|
cors_domain: Option<AccessControlAllowOrigin>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Endpoint for RpcEndpoint {
|
impl Endpoint for RpcEndpoint {
|
||||||
|
Loading…
Reference in New Issue
Block a user