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

PivotResponseWriter #39

Merged
merged 8 commits into from
Dec 10, 2024
Merged

PivotResponseWriter #39

merged 8 commits into from
Dec 10, 2024

Conversation

michielbdejong
Copy link
Collaborator

@michielbdejong michielbdejong commented Dec 4, 2024

Display containers even if trailing slash is missing from the URL

@michielbdejong michielbdejong changed the title PivotHandlerServerConfigurator PivotHttpHandler Dec 9, 2024
@michielbdejong michielbdejong force-pushed the handler-server-configurator branch from 202a385 to 9748bf3 Compare December 10, 2024 13:20
@michielbdejong michielbdejong marked this pull request as draft December 10, 2024 13:21
@michielbdejong
Copy link
Collaborator Author

I was able to wrap some own code around the http sequence handler.
Its output is undefined, but it calls methods on input.response.
I can see input.response.statusCode, and this would be the perfect place to catch 401/403/404 and rewrite to 301 if the resource exists after toggling the switch, except that when I try to call input.res.setHeader, it errors with:

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client

@michielbdejong
Copy link
Collaborator Author

I'm re-adding the code from #19 to see where that gets us:

-    // In the future we want to use getNormalizedMetadata and redirect in case the identifier differs
-    let metadata = await this.accessor.getMetadata(identifier);
+    // We use getNormalizedMetadata and redirect in case the identifier differs
+    let metadata = await this.getNormalizedMetadata(identifier);
+    // Redirect in case the identifier differs
+    if (metadata.identifier.value !== identifier.path) {
+      throw new RedirectHttpError(302, 'Found', metadata.identifier.value);
+    }

Actually while re-reading this I don't understand why it would lead to locking problems.

@michielbdejong
Copy link
Collaborator Author

Maybe I can hook into the BasicResponseWriter, here

@michielbdejong michielbdejong changed the title PivotHttpHandler PivotResponseWriter Dec 10, 2024
@michielbdejong michielbdejong marked this pull request as ready for review December 10, 2024 14:41
@michielbdejong
Copy link
Collaborator Author

Merging this so we can tag a release and test it.

@michielbdejong michielbdejong merged commit 02b520d into main Dec 10, 2024
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.

1 participant