Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for variable file extensions #18

Merged
merged 15 commits into from
Mar 23, 2021

Conversation

roblillack
Copy link
Owner

@roblillack roblillack commented May 22, 2019

Changes

  • htps://github.com/robfig/pathtree (no changes since ~7 years ago) is imported as internal/pathtree
  • Pathtree is adapted to include support for variable file extensions
  • Router tests are extended to test this specific feature

How to use this feature

Given a route definition like these:

  • GET /dir/:filename.:ext MyController.ExportFile (Basename of file is variable, too)
  • GET /dir/filename.:ext MyController.ExportExt (Basename of file is static, only extension is variable)
  • GET /dir/:filename.png MyController.ExportPNG (Basename of file is variable, extension is not; this was available before)
    you're now able to use Actions like these:
  • (c *MyController) ExportFile(filename, ext string) mars.Result (variable basename)
  • (c *MyController) ExportExt(ext string) mars.Result (static basename)
  • (c *MyController) ExportPNG(filename string) mars.Result (static extension)

Routes with fixed path with variable extension will always get higher priority than variable filename with fixed extension. So, a request to /dir/filename.png would be handled by ExportExt("png") instead of ExportPNG("filename") for the example above.

Ticket: #17

@coveralls
Copy link

coveralls commented May 22, 2019

Coverage Status

Coverage increased (+1.3%) to 60.517% when pulling 05ef321 on 17-add-support-for-variable-file-extensions into 20dbc79 on master.

@roblillack roblillack self-assigned this Mar 23, 2021
@roblillack roblillack force-pushed the 17-add-support-for-variable-file-extensions branch from e4689e1 to 05ef321 Compare March 23, 2021 08:08
@roblillack roblillack changed the title [WIP] Add support for variable file extensions Add support for variable file extensions Mar 23, 2021
@roblillack roblillack merged commit 60bd1e5 into master Mar 23, 2021
@roblillack roblillack deleted the 17-add-support-for-variable-file-extensions branch March 23, 2021 08:16
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.

None yet

4 participants