feat: add named index constants and document LocalFile - #82
Open
Rony-ZenAlden wants to merge 1 commit into
Open
Conversation
The second parameter of LocalFile is a bare bool whose meaning is not obvious at the call site, and it was undocumented (issue gin-contrib#45). Add a doc comment to LocalFile describing exactly what the indexes parameter controls, and export two named constants, ListDirectory (true) and NoListDirectory (false), so calls can read: static.LocalFile("/www", static.NoListDirectory) The constants are plain named bools, so existing true/false call sites keep compiling unchanged. Note: the parameter toggles automatic directory listing. An existing index.html is served regardless, so the constants are named after the listing behavior rather than the issue's suggested UseIndexHTML/ SkipIndexHTML, which would misrepresent that an index.html is still served when indexes is false. Add tests covering the constant values and the NoListDirectory behavior (index.html served, listing suppressed). Closes gin-contrib#45 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The second parameter of LocalFile is a bare bool whose meaning is not obvious at the call site, and it was undocumented (issue #45).
Add a doc comment to LocalFile describing exactly what the indexes parameter controls, and export two named constants, ListDirectory (true) and NoListDirectory (false), so calls can read:
The constants are plain named bools, so existing true/false call sites keep compiling unchanged.
Note: the parameter toggles automatic directory listing. An existing index.html is served regardless, so the constants are named after the listing behavior rather than the issue's suggested UseIndexHTML/ SkipIndexHTML, which would misrepresent that an index.html is still served when indexes is false.
Add tests covering the constant values and the NoListDirectory behavior (index.html served, listing suppressed).
Closes #45