Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

能否支持下NoRoute设置 #900

Closed
bsed opened this issue Apr 10, 2017 · 11 comments
Closed

能否支持下NoRoute设置 #900

bsed opened this issue Apr 10, 2017 · 11 comments
Assignees
Labels

Comments

@bsed
Copy link

bsed commented Apr 10, 2017

能否支持下NoRoute设置

r.NoRoute(func(c *gin.Context) {
		c.JSON(404, gin.H{
			"status":  "404",
			"message": "Not Found.",
		})
	})
@weisd
Copy link
Contributor

weisd commented Apr 11, 2017

不是有个NotFoundHandler吗?路由找不到会返回ErrNotFound, 可以设置echo.HTTPErrorHandler 在这处理所有错误

@bsed
Copy link
Author

bsed commented Apr 13, 2017

好的 谢谢~

@bsed bsed closed this as completed Apr 13, 2017
@zanjs
Copy link

zanjs commented May 15, 2017

@bsed 路由找不到 写在哪的

@bsed
Copy link
Author

bsed commented May 15, 2017

@zanjs 对啊。 问我现在用的是自定义错误 解决的
image

@zanjs
Copy link

zanjs commented May 15, 2017

@bsed 哦 这是 重写 HTTPErrorHandler 右边 handler.HTTPErrorHandler 你是怎么写的呀

@bsed
Copy link
Author

bsed commented May 15, 2017

你可以看看知乎上某位童鞋写的对 echo 框架进行统一的自定义错误处理 , 我的是在他 基础上修改的,希望对你有帮助。
需要稍微修改写就可以用了。
image

@bsed
Copy link
Author

bsed commented May 15, 2017

image
image
image

@bsed
Copy link
Author

bsed commented May 15, 2017

差不多 就这些了。

@zanjs
Copy link

zanjs commented May 15, 2017

@bsed 谢谢啦🙃

@bsed
Copy link
Author

bsed commented May 15, 2017

客气,客气、 @zanjs (^__^) ……

@vishr vishr self-assigned this May 16, 2017
@vishr vishr added the question label May 16, 2017
@mei-rune mei-rune mentioned this issue Mar 11, 2019
@mei-rune
Copy link

#2217

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

No branches or pull requests

5 participants