Skip to content

Commit e658051

Browse files
committed
fix: fixing routing to serve static files & api routes from same route
* bug-fix: add method guard to allow http methods in File Service in actix
1 parent 40a8bd1 commit e658051

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/server.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,22 @@ impl Server {
155155
if let Some(index_file) = &directory.index_file {
156156
app = app.service(
157157
Files::new(&directory.route, &directory.directory_path)
158+
.method_guard(guard::fn_guard(|_| true))
158159
.index_file(index_file)
159160
.redirect_to_slash_directory(),
160161
);
161162
} else if directory.show_files_listing {
162163
app = app.service(
163164
Files::new(&directory.route, &directory.directory_path)
165+
.method_guard(guard::fn_guard(|_| true))
164166
.redirect_to_slash_directory()
165167
.show_files_listing(),
166168
);
167169
} else {
168-
app = app
169-
.service(Files::new(&directory.route, &directory.directory_path));
170+
app = app.service(
171+
Files::new(&directory.route, &directory.directory_path)
172+
.method_guard(guard::fn_guard(|_| true)),
173+
);
170174
}
171175
}
172176

0 commit comments

Comments
 (0)