Chi: Chi should not panic when no routes

Created on 26 Nov 2018  路  4Comments  路  Source: go-chi/chi

Hello!

We use a generic service skeleton based on chi in our company. Sometimes we needn't handle http-request and our skeleton creates chi.Mux with no roures.

If someone try to ping our service, it fails with panic because of this if section.

I think Chi should return 404 error instead of panic.

Most helpful comment

Why don't you add a 404 handler in your skeleton app's code?

I'm not sure if this is the right call. The panic might be useful for some folks that forget to mount the handlers correctly.

Let's poll the community for their opinions:
馃憤 for HTTP 404; 馃憥 for keeping the panic as is; 馃帀 for panicking at the startup time

All 4 comments

Why don't you add a 404 handler in your skeleton app's code?

I'm not sure if this is the right call. The panic might be useful for some folks that forget to mount the handlers correctly.

Let's poll the community for their opinions:
馃憤 for HTTP 404; 馃憥 for keeping the panic as is; 馃帀 for panicking at the startup time

I understood your point, but in this case we create a service which can panic at the random moment when someone send any http request. And developer don't know about this behavior.

Maybe we should panic at service startup

@makhov that's a good point, thanks. Let me add it as a third option to the poll.

done in https://github.com/go-chi/chi/pull/378 -- in v4, we will return 404 for an empty mux

Was this page helpful?
0 / 5 - 0 ratings

Related issues

didip picture didip  路  7Comments

gpopovic picture gpopovic  路  5Comments

nhooyr picture nhooyr  路  12Comments

leighmcculloch picture leighmcculloch  路  8Comments

rocanion picture rocanion  路  4Comments