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

🚀 improve mounting behavior #2120

Merged
merged 13 commits into from Oct 25, 2022
Merged

🚀 improve mounting behavior #2120

merged 13 commits into from Oct 25, 2022

Conversation

efectn
Copy link
Member

@efectn efectn commented Sep 25, 2022

Description

Fixes #2066 and adds some features to mounting feature 🚀

  • Add OnMount hook that is fired when sub-app is mounted on a parent app.
  • Add MountPath method to app. It returns mount prefix of sub-app. If app not mounteed, it returns empty string.
  • Don't execute onRoute/OnGroup/OnName/OnGroupName hooks when to add routes of sub-apps to parent app. Return pathes with prefix for sub-app routes instead.
  • Don't add routes in Mount. Add them in startupProcess. We're now able to Mount app before adding routes (supoorting nested mounting).
  • Fix views when both of parent app and sub-app have different view engines

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • For new functionalities I follow the inspiration of the express js framework and built them similar in usage
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation - https://github.com/gofiber/docs for https://docs.gofiber.io/
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I tried to make my code as fast as possible with as few allocations as possible

Commit formatting:

Use emojis on commit messages so it provides an easy way of identifying the purpose or intention of a commit. Check out the emoji cheatsheet here: https://gitmoji.carloscuesta.me/

router.go Show resolved Hide resolved
@efectn efectn changed the title 🐛 bug: fix mounting doesn't work if when to declare it before routes 🐛 bug: fix mounting doesn't work if when to declare it before routes & improve routing behavior Sep 28, 2022
@efectn efectn changed the title 🐛 bug: fix mounting doesn't work if when to declare it before routes & improve routing behavior 🐛 bug: fix mounting doesn't work if when to declare it before routes & improve mounting behavior Sep 28, 2022
@efectn efectn changed the title 🐛 bug: fix mounting doesn't work if when to declare it before routes & improve mounting behavior 🐛 bug: improve mounting behavior Sep 28, 2022
…ame, onRoute, onGroup, onGroupName hooks on mounted apps
app.go Outdated Show resolved Hide resolved
app.go Show resolved Hide resolved
Copy link
Member

@ReneWerner87 ReneWerner87 left a comment

Choose a reason for hiding this comment

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

some little adjustments needed

app.go Outdated Show resolved Hide resolved
app.go Outdated Show resolved Hide resolved
Copy link
Member

@ReneWerner87 ReneWerner87 left a comment

Choose a reason for hiding this comment

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

code looks good, but i have made a few comments which should clean up the code and make it easier to read and understand

app.go Outdated Show resolved Hide resolved
ctx_test.go Outdated Show resolved Hide resolved
ctx_test.go Outdated Show resolved Hide resolved
app_test.go Outdated Show resolved Hide resolved
app.go Outdated Show resolved Hide resolved
app.go Outdated Show resolved Hide resolved
ctx_test.go Outdated Show resolved Hide resolved
@ReneWerner87 ReneWerner87 merged commit 156b81c into master Oct 25, 2022
@efectn efectn deleted the fix-sub-mounting branch October 25, 2022 12:28
@ReneWerner87 ReneWerner87 changed the title 🐛 bug: improve mounting behavior 🚀 improve mounting behavior Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 [Bug]: Mounting does not work if you use it before declaring the route
2 participants