Skip to content

Commit 5162607

Browse files
committed
feat(serverHandler): prevent output error information to end user
1 parent 7dd04c6 commit 5162607

File tree

6 files changed

+5
-24
lines changed

6 files changed

+5
-24
lines changed

src/serverHandler/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
6161

6262
// data
6363
data := h.getResponseData(r)
64-
if len(data.Errors) > 0 {
64+
if len(data.errors) > 0 {
6565
go func() {
66-
for _, err := range data.Errors {
66+
for _, err := range data.errors {
6767
h.errHandler.LogError(err)
6868
}
6969
}()

src/serverHandler/responseData.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type responseData struct {
4242

4343
hasNotFoundError bool
4444
hasInternalError bool
45+
errors []error
4546

4647
IsRoot bool
4748
Path string
@@ -57,7 +58,6 @@ type responseData struct {
5758
CanArchive bool
5859
CanCors bool
5960
NeedAuth bool
60-
Errors []error
6161
}
6262

6363
func isSlash(c rune) bool {
@@ -265,9 +265,9 @@ func (h *handler) getResponseData(r *http.Request) (data *responseData) {
265265

266266
rawReqPath := util.CleanUrlPath(requestUri)
267267
reqPath := util.CleanUrlPath(rawReqPath[len(h.urlPrefix):]) // strip url prefix path
268-
errs := []error{}
269268
notFound := false
270269
internalError := false
270+
errs := []error{}
271271

272272
isRoot := rawReqPath == "/"
273273

@@ -323,6 +323,7 @@ func (h *handler) getResponseData(r *http.Request) (data *responseData) {
323323

324324
hasNotFoundError: notFound,
325325
hasInternalError: internalError,
326+
errors: errs,
326327

327328
IsRoot: isRoot,
328329
Path: rawReqPath,
@@ -338,8 +339,6 @@ func (h *handler) getResponseData(r *http.Request) (data *responseData) {
338339
CanArchive: canArchive,
339340
CanCors: canCors,
340341
NeedAuth: needAuth,
341-
342-
Errors: errs,
343342
}
344343

345344
return

src/tpl/assert/main.css

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,6 @@ em {
213213
float: right;
214214
}
215215

216-
.error {
217-
margin: 1em;
218-
padding: 1em;
219-
background: #ffc;
220-
}
221-
222216
@media only screen and (max-width: 350px) {
223217
.item-list .time {
224218
display: none;

src/tpl/assert/main.css.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,6 @@ white-space: nowrap;
184184
overflow: hidden;
185185
float: right;
186186
}
187-
.error {
188-
margin: 1em;
189-
padding: 1em;
190-
background: #ffc;
191-
}
192187
@media only screen and (max-width: 350px) {
193188
.item-list .time {
194189
display: none;

src/tpl/page.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@
5656
{{end}}{{end}}
5757
</ul>
5858

59-
{{range .Errors}}
60-
<div class="error">{{.}}</div>
61-
{{end}}
62-
6359
<script type="text/javascript" src="{{.RootRelPath}}/../assert/main.js"></script>
6460
</body>
6561
</html>

src/tpl/page.html.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ const pageTplStr = `
6060
</li>
6161
{{end}}{{end}}
6262
</ul>
63-
{{range .Errors}}
64-
<div class="error">{{.}}</div>
65-
{{end}}
6663
<script type="text/javascript" src="{{.RootRelPath}}?assert=main.js"></script>
6764
</body>
6865
</html>

0 commit comments

Comments
 (0)