Comments (5)
模板文件都在这个目录下: internal/templates
, 本地测试正常。可以贴下你的访问方式。
from eagle.
当我访问一个不存在的路由时就重现错误了
http://localhost:8080/err 请求路由不存在的路由报如下错误
2020/12/17 22:38:00 [Recovery] 2020/12/17 - 22:38:00 panic recovered:
GET /favicon.ico HTTP/1.1
Host: localhost:8080
Accept: image/webp,image/apng,image/,/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Connection: keep-alive
Cookie: Phpstorm-963730c5=13220b42-a332-4f23-aec1-76fdf6d9933b; Hm_lvt_1d2d61263f13e4b288c8da19ad3ff56d=1601001166; Webstorm-8c079569=8575b6b7-f224-4821-9825-bc23dbb7b7bd
Referer: http://localhost:8080/
Sec-Fetch-Dest: image
Sec-Fetch-Mode: no-cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36
TemplateEngine render read name:error/404, path:D:\goworkspace\src\snake\internal\templates\error\404.html, error: open D:\goworkspace\src\snake\internal\templates\error\404.html: The system cannot find the path specified.
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/context.go:842 (0xe1c124)
(*Context).Render: panic(err)
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/context.go:851 (0xe1c1e4)
(*Context).HTML: c.Render(code, instance)
D:/goworkspace/src/snake/app/web/error.go:11 (0x1189664)
Error404: c.HTML(http.StatusOK, "error/404", gin.H{
D:/goworkspace/src/snake/router/web.go:24 (0x1189665)
LoadWebRouter.func1: web.Error404(c)
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0xe18061)
(*Context).Next: c.handlersc.index
D:/goworkspace/src/snake/router/middleware/requestid.go:28 (0x117b74c)
RequestID.func1: c.Next()
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0xe18061)
(*Context).Next: c.handlersc.index
D:/goworkspace/src/snake/router/middleware/header.go:24 (0x117a4e4)
Options: c.Next()
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0xe18061)
(*Context).Next: c.handlersc.index
D:/goworkspace/src/snake/router/middleware/header.go:16 (0x117a476)
NoCache: c.Next()
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0xe18061)
(*Context).Next: c.handlersc.index
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:83 (0xe2c726)
RecoveryWithWriter.func1: c.Next()
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0xe18061)
(*Context).Next: c.handlersc.index
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/logger.go:241 (0xe2b813)
LoggerWithConfig.func1: c.Next()
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0xe18061)
(*Context).Next: c.handlersc.index
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:445 (0xe229be)
serveError: c.Next()
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:438 (0xe225e4)
(*Engine).handleHTTPRequest: serveError(c, http.StatusNotFound, default404Body)
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:367 (0xe21f74)
(*Engine).ServeHTTP: engine.handleHTTPRequest(c)
D:/Go/src/net/http/server.go:2843 (0xbeeda9)
serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
D:/Go/src/net/http/server.go:1925 (0xbea3cc)
(*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
D:/Go/src/runtime/asm_amd64.s:1374 (0x841dc0)
goexit: BYTE $0x90 // NOP
from eagle.
我看了,你那边应该error/404.html 没有提交到master 上来吧
from eagle.
然后我拷贝了模板的index.html 复制到templates/error/404.html ,访问不存在的路由就没有问题了,但如果不继承模板又会报错
报错如下
2020/12/17 22:45:48 [Recovery] 2020/12/17 - 22:45:48 panic recovered:
GET /err HTTP/1.1
Host: localhost:8080
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Cache-Control: max-age=0
Connection: keep-alive
Cookie: Hm_lvt_1d2d61263f13e4b288c8da19ad3ff56d=1601001166
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: cross-site
Sec-Fetch-User: ?1
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36
TemplateEngine execute template error: html/template:layouts/master:23:15: no such template "content"
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/context.go:842 (0x159c124)
(*Context).Render: panic(err)
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/context.go:851 (0x159c1e4)
(*Context).HTML: c.Render(code, instance)
D:/goworkspace/src/snake/app/web/error.go:11 (0x1909664)
Error404: c.HTML(http.StatusOK, "error/404", gin.H{
D:/goworkspace/src/snake/router/web.go:24 (0x1909665)
LoadWebRouter.func1: web.Error404(c)
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0x1598061)
(*Context).Next: c.handlersc.index
D:/goworkspace/src/snake/router/middleware/requestid.go:28 (0x18fb74c)
RequestID.func1: c.Next()
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0x1598061)
(*Context).Next: c.handlersc.index
D:/goworkspace/src/snake/router/middleware/header.go:24 (0x18fa4e4)
Options: c.Next()
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0x1598061)
(*Context).Next: c.handlersc.index
D:/goworkspace/src/snake/router/middleware/header.go:16 (0x18fa476)
NoCache: c.Next()
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0x1598061)
(*Context).Next: c.handlersc.index
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:83 (0x15ac726)
RecoveryWithWriter.func1: c.Next()
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0x1598061)
(*Context).Next: c.handlersc.index
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/logger.go:241 (0x15ab813)
LoggerWithConfig.func1: c.Next()
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0x1598061)
(*Context).Next: c.handlersc.index
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:445 (0x15a29be)
serveError: c.Next()
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:438 (0x15a25e4)
(*Engine).handleHTTPRequest: serveError(c, http.StatusNotFound, default404Body)
D:/goworkspace/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:367 (0x15a1f74)
(*Engine).ServeHTTP: engine.handleHTTPRequest(c)
D:/Go/src/net/http/server.go:2843 (0x136eda9)
serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
D:/Go/src/net/http/server.go:1925 (0x136a3cc)
(*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
D:/Go/src/runtime/asm_amd64.s:1374 (0xfc1dc0)
goexit: BYTE $0x90 // NOP
from eagle.
对,之前没有添加会报错,已添加。
from eagle.
Related Issues (20)
- docker-compose up -d 报错 HOT 1
- 数据库 是否 支持 postgresql ? HOT 8
- 能否提供一个只有http server 没有grpc的latout 模板 HOT 3
- wire生成wire_gen.go文件报错 HOT 5
- 密码加解密不对 HOT 2
- 项目的用户密码加密功能被取消了吗 HOT 2
- 脚手架的日志怎么都在根目录啊 HOT 2
- 为什么cron作为main包加载, 而不是作为init启动时直接加载呢? 这么设计有什么目的吗? HOT 1
- 微信交流群二维码已过期 HOT 1
- 请问 log 不支持 Debug 级别是出于什么考虑呢? HOT 5
- 这不是完全模仿kratos 得嘛,有啥优势 HOT 1
- make build 时候出现错误 HOT 8
- jwt token 验证 err: input does not match formatfmt.Sscanf HOT 1
- internal/routers/router.go line 70: apiV1.Use(middleware.Auth())报错 HOT 2
- 列消息队列支持-RabbitMQ或Kafak HOT 4
- Should Depend On sqlite3 v1.14.15 Instead of v2.01 HOT 1
- invalid argument "eagle:github.com/go-eagle/eagle/pkg/version" for "-t, --tag" flag: invalid reference format HOT 1
- page_value 跟 last_id 是啥关系 HOT 5
- code, msg 返回异常。grpc请求符合预期,http请求不符合预期【已经解决, 更新eagle版本】 HOT 12
- 我该如何给基于grpc的http请求返回设置headers? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eagle.