echo icon indicating copy to clipboard operation
echo copied to clipboard

fix panic when both handler and middlewares are nil

Open ttrasn opened this issue 1 year ago • 4 comments

ttrasn avatar Aug 07 '23 13:08 ttrasn

could you explain why this case should act as no-op instead of panic? most of the cases I think providing nil for these value should be considered as something going very wrong.

aldas avatar Aug 07 '23 13:08 aldas

Showing a 404 error is better than showing a panic error. I don't think it's possible for someone to intentionally not send the handler and only set the route. An empty handler is like the absence of that page. So 404 is more suitable.

ttrasn avatar Aug 07 '23 13:08 ttrasn

Hi @aldas, could you please check this PR?

ttrasn avatar Sep 19 '23 10:09 ttrasn

I really do not want to accept this behavior.

Probably just doing this is better

	if handler == nil {
		panic("can not add route with nil handler")
	}

to fail fast and before even the server is started. Adding route without handler is something deeply wrong in developers code.

aldas avatar Sep 19 '23 21:09 aldas