mirror of
https://github.com/agersant/polaris
synced 2024-11-10 10:14:12 +00:00
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.vfs_manager))
|
||||
.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(
|
||||
actix_files::Files::new(&context.swagger_url, context.swagger_dir_path)
|
||||
.redirect_to_slash_directory()
|
||||
.index_file("index.html"),
|
||||
)
|
||||
.service(
|
||||
actix_files::Files::new(&context.web_url, context.web_dir_path)
|
||||
.redirect_to_slash_directory()
|
||||
.index_file("index.html"),
|
||||
);
|
||||
}
|
||||
|
@ -44,8 +51,6 @@ pub fn run(context: service::Context) -> Result<()> {
|
|||
App::new()
|
||||
.wrap(Logger::default())
|
||||
.wrap(Compress::default())
|
||||
.wrap_fn(api::http_auth_middleware)
|
||||
.wrap(NormalizePath::new(TrailingSlash::Trim))
|
||||
.configure(make_config(context.clone()))
|
||||
})
|
||||
.disable_signals()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use actix_web::{
|
||||
client::ClientResponse,
|
||||
middleware::{normalize::TrailingSlash, Compress, Logger, NormalizePath},
|
||||
middleware::{Compress, Logger},
|
||||
rt::{System, SystemRunner},
|
||||
test,
|
||||
test::*,
|
||||
|
@ -117,8 +117,6 @@ impl TestService for ActixTestService {
|
|||
App::new()
|
||||
.wrap(Logger::default())
|
||||
.wrap(Compress::default())
|
||||
.wrap_fn(api::http_auth_middleware)
|
||||
.wrap(NormalizePath::new(TrailingSlash::Trim))
|
||||
.configure(config)
|
||||
});
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ fn test_swagger_can_get_index() {
|
|||
let request = protocol::swagger_index();
|
||||
let response = service.fetch(&request);
|
||||
let status = response.status();
|
||||
assert!(status == StatusCode::OK || status == StatusCode::PERMANENT_REDIRECT);
|
||||
assert_eq!(status, StatusCode::FOUND);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue