Skip to content

Replace gorilla/mux dependency with http.ServeMux#7676

Merged
anderseknert merged 1 commit intoopen-policy-agent:mainfrom
anderseknert:http-servemux
Jun 9, 2025
Merged

Replace gorilla/mux dependency with http.ServeMux#7676
anderseknert merged 1 commit intoopen-policy-agent:mainfrom
anderseknert:http-servemux

Conversation

@anderseknert
Copy link
Copy Markdown
Member

I was curious to see how much work this would entail, and it turned out to be... some :) Particularly porting some of the features exposed as settings by gorilla mux, like removing trailing slashes, or escaping / in matched paths.

This change is breaking by necessity, as some public functions previously accepted arguments straight from the mux library. I don't really see any way around that if we want to get rid of the dependency. I don't think that too many external projects use code from the server directly though, so I'm thinking the impact should be minimal? Happy to hear what others think.

I was curious to see how much work this would entail, and it turned out to
be... some :) Particularly porting some of the features exposed as settings
by gorilla mux, like removing trailing slashes, or escaping `/` in matched
paths.

This change is breaking by necessity, as some public functions previously
accepted arguments straight from the mux library. I don't really see any
way around that if we want to get rid of the dependency. I don't think
that too many external projects use code from the server directly though,
so I'm thinking the impact should be minimal? Happy to hear what others
think.

Signed-off-by: Anders Eknert <anders@styra.com>
@anderseknert anderseknert merged commit dfb4d0b into open-policy-agent:main Jun 9, 2025
50 of 51 checks passed
@anderseknert anderseknert deleted the http-servemux branch June 9, 2025 23:47
@deeglaze
Copy link
Copy Markdown
Contributor

I'm attempting to update to the 1.6.0 release and find that without mux's Use function to interpose middleware, I don't see a particularly usable way to impose rate limits on serving. There's no way from .Serve to impose a wrapping of the router after mainRouter has its OPA handles added.

@srenatus
Copy link
Copy Markdown
Contributor

srenatus commented Jul 31, 2025

@deeglaze hey there! You're not alone, I've become aware of this recently, too. To improve the situation without going back to gorilla/mux, we've got #7789 now. It'll be part of the next release. Please let me know if it's sufficient for your use case or if it's not covering it. Sorry for the inconvenience 😉

@srenatus srenatus mentioned this pull request Jul 31, 2025
@deeglaze
Copy link
Copy Markdown
Contributor

That was wildly fast. I can confirm this works for me. Thank you.

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