Skip to content

feat: add named index constants and document LocalFile - #82

Open
Rony-ZenAlden wants to merge 1 commit into
gin-contrib:masterfrom
Rony-ZenAlden:feat/localfile-index-constants
Open

feat: add named index constants and document LocalFile#82
Rony-ZenAlden wants to merge 1 commit into
gin-contrib:masterfrom
Rony-ZenAlden:feat/localfile-index-constants

Conversation

@Rony-ZenAlden

Copy link
Copy Markdown

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:

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 #45

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>
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.

[Feature request] Add slightly more documentation for the parameters in static.LocalFile

1 participant