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

middleware: Add strip prefix middleware #875

Merged
merged 1 commit into from
Sep 18, 2024
Merged

Conversation

m1k1o
Copy link
Contributor

@m1k1o m1k1o commented Nov 19, 2023

Just wrapper over http.StripPrefix that can be used as r.Use(middleware.StripPrefix("/api")).

@m1k1o m1k1o changed the title Add strip prefix middleware middleware: Add strip prefix middleware Mar 31, 2024
@m1k1o
Copy link
Contributor Author

m1k1o commented Jun 1, 2024

@pkieltyka could you please review this small PR?

Copy link
Contributor

@VojtechVitek VojtechVitek left a comment

Choose a reason for hiding this comment

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

LGTM

@VojtechVitek
Copy link
Contributor

Tested with

	r := chi.NewRouter()
	
	r.Route("/_api", func(r chi.Router) {
		r.Use(middleware.StripPrefix("/_api"))
		r.Use(middleware.Heartbeat("/ping"))

		r.Handle("/rpc/*", rpcServerHandler)
	})

and it works well. 🎉

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.

2 participants