Conversation

ttrasn

No description provided.

@aldas

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.

@ttrasn

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

Hi @aldas, could you please check this PR?

@aldas

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.

return true
}
}
return false
Copy link
Author

Choose a reason for hiding this comment

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

You mean when both of them were nil ?

Suggested change
return false
panic("can not add route with nil handler and middlewares")

Sign up for free to join this conversation on . Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.