Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5adbe97

Browse files
author
xuxinhua
committed
404公益页面;NotFound 页面
1 parent 6b47e76 commit 5adbe97

File tree

5 files changed

+22
-10
lines changed

5 files changed

+22
-10
lines changed

websites/code/studygolang/src/controller/error.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,9 @@ func NoAuthorizeHandler(rw http.ResponseWriter, req *http.Request) {
1616
}
1717

1818
func NotFoundHandler(rw http.ResponseWriter, req *http.Request) {
19+
req.Form.Set(filter.CONTENT_TPL_KEY, "/template/notfound.html")
20+
}
21+
22+
func LossChildrenHandler(rw http.ResponseWriter, req *http.Request) {
1923
req.Form.Set(filter.CONTENT_TPL_KEY, "/template/404.html")
2024
}

websites/code/studygolang/src/server/studygolang/router.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,10 @@ func initRouter() *mux.Router {
218218

219219
// 错误处理handler
220220
router.FilterChain(fontFilterChan).HandleFunc("/noauthorize", NoAuthorizeHandler) // 无权限handler
221-
// 404页面
221+
// 404(寻找遗失儿童页面)
222+
router.FilterChain(fontFilterChan).HandleFunc("/404", LossChildrenHandler)
223+
224+
// 找不到页面
222225
router.FilterChain(fontFilterChan).HandleFunc("/{*}", NotFoundHandler)
223226

224227
return router

websites/code/studygolang/template/404.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
{{define "topnav"}}
2-
<li class="first last active"><a href="/">返回首页</a></li>
3-
{{end}}
1+
{{define "title"}}对不起,此页面不存在 {{end}}
2+
{{define "seo"}}<meta name="keywords" content="Go语言,Golang,Go社区,Go中文社区,Golang中文社区,Go语言社区,Go语言学习,学习Go语言,Go语言学习园地,Golang 中国,Golang中国,Golang China, Go语言论坛">
3+
<meta name="description" content="Go语言中文网,中国 Golang 社区,Go语言学习园地,致力于构建完善的 Golang 中文社区,Go语言爱好者的学习家园。分享 Go 语言知识,交流使用经验">{{end}
44
{{define "content"}}
55
<div id="main" class="container-fluid">
66
<div class="content">
@@ -9,13 +9,12 @@ <h2>对不起,此页面不存在</h2>
99
</div>
1010
</div>
1111
{{end}}
12-
{{define "title"}}对不起,此页面不存在 {{end}}
1312
{{define "js"}}
1413
<script type="text/javascript">
1514
function countDown(secs, surl){
1615
var jumpTo = document.getElementById('jumpTo');
1716
jumpTo.innerHTML=secs;
18-
if(--secs>0){
17+
if (--secs > 0){
1918
setTimeout("countDown("+secs+",'"+surl+"')",1000);
2019
} else {
2120
location.href=surl;

websites/code/studygolang/template/noauthorize.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
{{define "topnav"}}
2-
<li class="first last active"><a href="/">返回首页</a></li>
3-
{{end}}
1+
{{define "title"}}对不起,没有操作权限 {{end}}
2+
{{define "seo"}}<meta name="keywords" content="Go语言,Golang,Go社区,Go中文社区,Golang中文社区,Go语言社区,Go语言学习,学习Go语言,Go语言学习园地,Golang 中国,Golang中国,Golang China, Go语言论坛">
3+
<meta name="description" content="Go语言中文网,中国 Golang 社区,Go语言学习园地,致力于构建完善的 Golang 中文社区,Go语言爱好者的学习家园。分享 Go 语言知识,交流使用经验">{{end}
44
{{define "content"}}
55
<div id="main" class="container-fluid">
66
<div class="content">
@@ -9,7 +9,6 @@ <h2>对不起,您没有操作权限</h2>
99
</div>
1010
</div>
1111
{{end}}
12-
{{define "title"}}对不起,没有操作权限 {{end}}
1312
{{define "js"}}
1413
<script type="text/javascript">
1514
function countDown(secs, surl){
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{{define "title"}}寻找遗失儿童 {{end}}
2+
{{define "seo"}}<meta name="keywords" content="Go语言,Golang,Go社区,Go中文社区,Golang中文社区,Go语言社区,Go语言学习,学习Go语言,Go语言学习园地,Golang 中国,Golang中国,Golang China, Go语言论坛">
3+
<meta name="description" content="Go语言中文网,中国 Golang 社区,Go语言学习园地,致力于构建完善的 Golang 中文社区,Go语言爱好者的学习家园。分享 Go 语言知识,交流使用经验">{{end}}
4+
{{define "content"}}{{end}}
5+
{{define "js"}}
6+
<script type="text/javascript" src="http://www.qq.com/404/search_children.js" charset="utf-8"></script>
7+
{{end}}

0 commit comments

Comments
 (0)