Fixed a bug where only swagger index could be accessed without trailing slash
This commit is contained in:
parent
ec39e696bb
commit
d4c78a0a31
3 changed files with 10 additions and 7 deletions
|
@ -25,13 +25,20 @@ pub fn make_config(context: service::Context) -> impl FnOnce(&mut ServiceConfig)
|
||||||
.app_data(web::Data::new(context.user_manager))
|
.app_data(web::Data::new(context.user_manager))
|
||||||
.app_data(web::Data::new(context.vfs_manager))
|
.app_data(web::Data::new(context.vfs_manager))
|
||||||
.app_data(web::Data::new(encryption_key))
|
.app_data(web::Data::new(encryption_key))
|
||||||
.service(web::scope(&context.api_url).configure(api::make_config()))
|
.service(
|
||||||
|
web::scope(&context.api_url)
|
||||||
|
.configure(api::make_config())
|
||||||
|
.wrap_fn(api::http_auth_middleware)
|
||||||
|
.wrap(NormalizePath::new(TrailingSlash::Trim)),
|
||||||
|
)
|
||||||
.service(
|
.service(
|
||||||
actix_files::Files::new(&context.swagger_url, context.swagger_dir_path)
|
actix_files::Files::new(&context.swagger_url, context.swagger_dir_path)
|
||||||
|
.redirect_to_slash_directory()
|
||||||
.index_file("index.html"),
|
.index_file("index.html"),
|
||||||
)
|
)
|
||||||
.service(
|
.service(
|
||||||
actix_files::Files::new(&context.web_url, context.web_dir_path)
|
actix_files::Files::new(&context.web_url, context.web_dir_path)
|
||||||
|
.redirect_to_slash_directory()
|
||||||
.index_file("index.html"),
|
.index_file("index.html"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -44,8 +51,6 @@ pub fn run(context: service::Context) -> Result<()> {
|
||||||
App::new()
|
App::new()
|
||||||
.wrap(Logger::default())
|
.wrap(Logger::default())
|
||||||
.wrap(Compress::default())
|
.wrap(Compress::default())
|
||||||
.wrap_fn(api::http_auth_middleware)
|
|
||||||
.wrap(NormalizePath::new(TrailingSlash::Trim))
|
|
||||||
.configure(make_config(context.clone()))
|
.configure(make_config(context.clone()))
|
||||||
})
|
})
|
||||||
.disable_signals()
|
.disable_signals()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
client::ClientResponse,
|
client::ClientResponse,
|
||||||
middleware::{normalize::TrailingSlash, Compress, Logger, NormalizePath},
|
middleware::{Compress, Logger},
|
||||||
rt::{System, SystemRunner},
|
rt::{System, SystemRunner},
|
||||||
test,
|
test,
|
||||||
test::*,
|
test::*,
|
||||||
|
@ -117,8 +117,6 @@ impl TestService for ActixTestService {
|
||||||
App::new()
|
App::new()
|
||||||
.wrap(Logger::default())
|
.wrap(Logger::default())
|
||||||
.wrap(Compress::default())
|
.wrap(Compress::default())
|
||||||
.wrap_fn(api::http_auth_middleware)
|
|
||||||
.wrap(NormalizePath::new(TrailingSlash::Trim))
|
|
||||||
.configure(config)
|
.configure(config)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ fn test_swagger_can_get_index() {
|
||||||
let request = protocol::swagger_index();
|
let request = protocol::swagger_index();
|
||||||
let response = service.fetch(&request);
|
let response = service.fetch(&request);
|
||||||
let status = response.status();
|
let status = response.status();
|
||||||
assert!(status == StatusCode::OK || status == StatusCode::PERMANENT_REDIRECT);
|
assert_eq!(status, StatusCode::FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Reference in a new issue