Skip to content

Commit

Permalink
Fix default index file
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonbaeten committed Oct 27, 2023
1 parent 17a7e34 commit 73e15d8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ members = [
resolver = "2"

[workspace.package]
version = "0.2.1"
version = "0.2.2"
edition = "2021"
license = "Apache-2.0 OR MIT"
repository = "https://github.com/tweedegolf/memory-serve"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ the following configuration methods:

| method | Default value | Description |
|----------------------|-------------------------|-------------------------------------------------------|
| `index_file` | `Some("index.html")` | Which file to serve on the route "/" |
| `index_file` | `Some("/index.html")` | Which file to serve on the route "/" |
| `fallback` | `None` | Which file to serve if no routed matched the request |
| `fallback_status` | `StatusCode::NOT_FOUND` | The HTTP status code to routes that did not match |
| `enable_gzip` | `true` | Allow to serve gzip encoded files |
Expand Down
8 changes: 5 additions & 3 deletions memory-serve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
//!
//! | method | Default value | Description |
//! |-----------------------------------|-------------------------|-------------------------------------------------------|
//! | [MemoryServe::index_file] | `Some("index.html")` | Which file to serve on the route "/" |
//! | [MemoryServe::index_file] | `Some("/index.html")` | Which file to serve on the route "/" |
//! | [MemoryServe::fallback] | `None` | Which file to serve if no routed matched the request |
//! | [MemoryServe::fallback_status] | `StatusCode::NOT_FOUND` | The HTTP status code to routes that did not match |
//! | [MemoryServe::enable_gzip] | `true` | Allow to serve gzip encoded files |
Expand Down Expand Up @@ -156,7 +156,7 @@ struct ServeOptions {
impl Default for ServeOptions {
fn default() -> Self {
Self {
index_file: Some("index.html"),
index_file: Some("/index.html"),
fallback: None,
fallback_status: StatusCode::NOT_FOUND,
html_cache_control: CacheControl::Short,
Expand Down Expand Up @@ -508,7 +508,9 @@ mod tests {

#[tokio::test]
async fn index_file() {
let memory_router = MemoryServe::new(load_assets!("static")).into_router();
let memory_router = MemoryServe::new(load_assets!("static"))
.index_file(None)
.into_router();

let (code, _) = get(memory_router.clone(), "/", "accept", "*").await;
assert_eq!(code, 404);
Expand Down

0 comments on commit 73e15d8

Please sign in to comment.