Skip to content

middleware: Add strip prefix middleware#875

Merged
VojtechVitek merged 1 commit into
go-chi:masterfrom
m1k1o:master
Sep 18, 2024
Merged

middleware: Add strip prefix middleware#875
VojtechVitek merged 1 commit into
go-chi:masterfrom
m1k1o:master

Conversation

@m1k1o

@m1k1o m1k1o commented Nov 19, 2023

Copy link
Copy Markdown
Contributor

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

m1k1o commented Jun 1, 2024

Copy link
Copy Markdown
Contributor Author

@pkieltyka could you please review this small PR?

@VojtechVitek VojtechVitek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@VojtechVitek

Copy link
Copy Markdown
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