Skip to content

Add support for custom 404 document#38

Merged
radu-matei merged 2 commits into
spinframework:mainfrom
ThorstenHans:feature/custom-404
Aug 28, 2023
Merged

Add support for custom 404 document#38
radu-matei merged 2 commits into
spinframework:mainfrom
ThorstenHans:feature/custom-404

Conversation

@ThorstenHans
Copy link
Copy Markdown
Contributor

With this PR spin-fileserver can be configured to serve a custom 404 document instead of returning the default 404 Not Found response using the CUSTOM_404_PATH environment variable.

If the path specified in CUSTOM_404_PATH doesn't exist, the default 404 Not Found response is returned to the user.

Signed-off-by: Thorsten Hans <thorsten.hans@gmail.com>
Copy link
Copy Markdown
Contributor

@itowlson itowlson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a couple of non-blocking suggestions and clarifications.

Comment thread readme.md Outdated
Comment thread readme.md Outdated
Comment thread readme.md Outdated

### Using a custom 404 document

You can configure a `CUSTOM_404_PATH` environment variable that points to a file that will be served instead of returning a plain 404 Not Found response. If the `CUSTOM_404_PATH` environment variable is not set or points to a non-existing file, the default 404 Not Found response is returned.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly worth noting that the custom 404 file has to be included as an asset. (This might not "just happen" if, say, the file server was configured to serve the /images directory instead of the whole site.) And that the path is the mount path inside the fileserver component. (In your example, the source file would have to be test/custom-404.html in order to get mounted as custom-404.html.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've rewritten the paragraph, maybe you can check again @itowlson

Signed-off-by: Thorsten Hans <thorsten.hans@gmail.com>
Copy link
Copy Markdown
Member

@radu-matei radu-matei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks for your contribution, @ThorstenHans!

@radu-matei radu-matei merged commit 308d842 into spinframework:main Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants