7f5dd134 by Unknown

Fixed bug: error page cannot show correct corresponding status code

1 parent 7f4ad7ff
...@@ -189,6 +189,7 @@ func NotFound(rw http.ResponseWriter, r *http.Request) { ...@@ -189,6 +189,7 @@ func NotFound(rw http.ResponseWriter, r *http.Request) {
189 "<br>You like 404 pages" + 189 "<br>You like 404 pages" +
190 "</ul>") 190 "</ul>")
191 data["BeegoVersion"] = VERSION 191 data["BeegoVersion"] = VERSION
192 rw.WriteHeader(http.StatusNotFound)
192 t.Execute(rw, data) 193 t.Execute(rw, data)
193 } 194 }
194 195
...@@ -204,6 +205,7 @@ func Unauthorized(rw http.ResponseWriter, r *http.Request) { ...@@ -204,6 +205,7 @@ func Unauthorized(rw http.ResponseWriter, r *http.Request) {
204 "<br>Check the address for errors" + 205 "<br>Check the address for errors" +
205 "</ul>") 206 "</ul>")
206 data["BeegoVersion"] = VERSION 207 data["BeegoVersion"] = VERSION
208 rw.WriteHeader(http.StatusUnauthorized)
207 t.Execute(rw, data) 209 t.Execute(rw, data)
208 } 210 }
209 211
...@@ -220,6 +222,7 @@ func Forbidden(rw http.ResponseWriter, r *http.Request) { ...@@ -220,6 +222,7 @@ func Forbidden(rw http.ResponseWriter, r *http.Request) {
220 "<br>You need to log in" + 222 "<br>You need to log in" +
221 "</ul>") 223 "</ul>")
222 data["BeegoVersion"] = VERSION 224 data["BeegoVersion"] = VERSION
225 rw.WriteHeader(http.StatusForbidden)
223 t.Execute(rw, data) 226 t.Execute(rw, data)
224 } 227 }
225 228
...@@ -235,6 +238,7 @@ func ServiceUnavailable(rw http.ResponseWriter, r *http.Request) { ...@@ -235,6 +238,7 @@ func ServiceUnavailable(rw http.ResponseWriter, r *http.Request) {
235 "<br>Please try again later." + 238 "<br>Please try again later." +
236 "</ul>") 239 "</ul>")
237 data["BeegoVersion"] = VERSION 240 data["BeegoVersion"] = VERSION
241 rw.WriteHeader(http.StatusServiceUnavailable)
238 t.Execute(rw, data) 242 t.Execute(rw, data)
239 } 243 }
240 244
...@@ -249,6 +253,7 @@ func InternalServerError(rw http.ResponseWriter, r *http.Request) { ...@@ -249,6 +253,7 @@ func InternalServerError(rw http.ResponseWriter, r *http.Request) {
249 "<br>you should report the fault to the website administrator" + 253 "<br>you should report the fault to the website administrator" +
250 "</ul>") 254 "</ul>")
251 data["BeegoVersion"] = VERSION 255 data["BeegoVersion"] = VERSION
256 rw.WriteHeader(http.StatusInternalServerError)
252 t.Execute(rw, data) 257 t.Execute(rw, data)
253 } 258 }
254 259
......
...@@ -445,6 +445,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) ...@@ -445,6 +445,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
445 //if no matches to url, throw a not found exception 445 //if no matches to url, throw a not found exception
446 if !findrouter { 446 if !findrouter {
447 if h, ok := ErrorMaps["404"]; ok { 447 if h, ok := ErrorMaps["404"]; ok {
448 w.status = 404
448 h(w, r) 449 h(w, r)
449 } else { 450 } else {
450 http.NotFound(w, r) 451 http.NotFound(w, r)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!