Skip to content

fix: top-level links based on request_path if present - #467

Draft
grzuy wants to merge 1 commit into
beam-community:mainfrom
pdqcom:fix-toplevel-links-path
Draft

grzuy wants to merge 1 commit into
beam-community:mainfrom
pdqcom:fix-toplevel-links-path

Conversation

@grzuy

@grzuy grzuy commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Closes #466

Thoughts on defaulting to Conn.request_path to fix this?

Another option would be to allow the View/Serializer to receive this per-operation path as an argument during a request/response cycle somehow, right?

@mattpolzin

Copy link
Copy Markdown
Member

I think the tricky thing here is that the existing strategy and the one you are proposing both have strengths and weaknesses.

As you note, the existing strategy fails to automatically apply to two distinct routes both surfacing the same primary resource using the same view.

On the other hand, your new strategy fails to automatically handle reverse-proxying that would make the request path as seen in the Elixir service not accurate to the outside world.

Each weakness is the other strategy's strength, too. The existing strategy works well in reverse proxied settings because it produces a canonical external URL. Your new strategy works well in multiple route situations because it does not rely on the assumption that a resource is served from one canonical route.

In the end, given the fact that all of this is nearly infinitely customizable by the library (you can write your own url_for and you can write your own url_for_pagination and you can write your own Pagination module), I am not sure how to pick the "best" default behavior other than to leave it alone since that is the option that is non-breaking.

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.

Top-level links are wrong when getting related resources

2 participants