mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vweb: add an overridable .not_found() method, for making a custom 404 page + tests fixes (#17936)
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
import os
|
||||
import time
|
||||
import json
|
||||
import net
|
||||
import net.http
|
||||
import io
|
||||
|
||||
const (
|
||||
sport = 12382
|
||||
@@ -91,6 +88,21 @@ fn test_other_path() {
|
||||
assert x.body == 'Other path'
|
||||
}
|
||||
|
||||
fn test_different_404() {
|
||||
res_app := http.get('http://${localserver}/zxcnbnm') or { panic(err) }
|
||||
assert res_app.status() == .not_found
|
||||
assert res_app.body == '404 From App'
|
||||
|
||||
res_admin := http.get('http://${localserver}/admin/JHKAJA') or { panic(err) }
|
||||
assert res_admin.status() == .not_found
|
||||
assert res_admin.body == '404 From Admin'
|
||||
|
||||
// Other doesn't have a custom 404 so the vweb.Context's not_found is expected
|
||||
res_other := http.get('http://${localserver}/other/unknown') or { panic(err) }
|
||||
assert res_other.status() == .not_found
|
||||
assert res_other.body == '404 Not Found'
|
||||
}
|
||||
|
||||
fn test_shutdown() {
|
||||
// This test is guaranteed to be called last.
|
||||
// It sends a request to the server to shutdown.
|
||||
|
||||
Reference in New Issue
Block a user