Skip to content

Added support to handle multi-page apps from gofr #1614

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

Open
wants to merge 4 commits into
base: development
Choose a base branch
from

Conversation

im-ng
Copy link

@im-ng im-ng commented Mar 27, 2025

Changes include:

  1. Enable MPA support

This PR intends to enable the GOFR to handle multi-page application development without limiting the GOFR to supporting JSON responses alone. In order to support MPA, the responders (File, Raw, and Template) have to be upgraded to allow them to set custom headers and cookies to start with. This can also be extended to support sessions.

The changes included here help the GOFR user to write an HTML page using a templ or template format and include the necessary cookie to navigate across the pages without the need for any frontend framework such as React, Vue, and so on.

  1. Allow the GOFR to capture the PUBLIC keys immediately without needing to wait for the refresh interval to expire. Assume if someone set the refresh interval larger (1800 seconds), the authentication would fail.

Breaking Changes (if applicable):

  • None

Additional Information:

  • None

@coolwednesday
Copy link
Contributor

@im-ng, please address any linter or Code Climate issues in the PR.

It would also be helpful to include the motivation behind this PR. If possible, consider creating a GitHub issue explaining the problem you faced and linking it in the PR. If an issue already exists, you can reference it using fixes #issue_number or closes #issue_number.

This makes it easier for reviewers and maintainers to understand the context and prioritize the changes accordingly. Thanks! 😊

@im-ng
Copy link
Author

im-ng commented Mar 28, 2025

@coolwednesday Updated necessary comments, lint part in this PR.

@vikash
Copy link
Contributor

vikash commented Apr 12, 2025

For gofr's focus on being the framework for Microservices, is cookie a valid use-case? Specially when it changes (adds fields and thus complexity) to the common structs. This does not feel a right addition to the framework.

@im-ng
Copy link
Author

im-ng commented Apr 14, 2025

Thanks for the feedback. This PR intends to enable session management for the multi-page application, as the framework does not have to limit itself to a stateless authorization header.

I see the custom headers were introduced in the 1.28.x (common struct) version, as Gofr finds more use cases to adjust itself to support the x-refresh-token or more. As the framework grows in the hands of users, I thought it would be a good addition to allow one to set the needed JWT or secure tokens using the cookie itself for MPA.

As we observe increasing traction surrounding server-side rendering, templates, and HTMX, enabling such capabilities assists one in utilizing Gofr as their framework.

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.

4 participants