chi icon indicating copy to clipboard operation
chi copied to clipboard

Not throwing method not allowed, when I have not allowed a PUT method and have a POST method

Open SoulPancake opened this issue 7 months ago • 1 comments

I have a POST method using a custom middleware

	`r.With(middleware.AuthMiddleware).Method(http.MethodPost, "/something", handlers.Handler(someHandler))`

and for this /something there is no other route or other method mentioned anywhere So My expectation is the chi should throw a 405 method not allowed and it seems to work for other cases, however for this POST ( originally ), hitting PUT method, it doesn't throw a 405 and just redirects to some random route.

Is there something I am missing? Or some configuration I am supposed to additionally do or remove to fix this?

SoulPancake avatar May 16 '25 07:05 SoulPancake

Hi @SoulPancake, you need to create Custom Handler for this. You can follow this documentation https://go-chi.io/#/pages/routing?id=making-custom-404-and-405-handlers

boyzgenk avatar May 26 '25 18:05 boyzgenk