The current method can only support 404 and 405 states I can't use either of these methods when I need to globally control other states I think we can enhance this function, the user can register (code StateCode,handlers ...HandlerFunc) and then do somethings...

Comment From: MikeJackOne

That's a good proposal,you can implement it yourself and open a PR.