Tests: Go application tests.
This commit is contained in:
6
test/go/404/404.html
Normal file
6
test/go/404/404.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<html>
|
||||
<head><title>404 Not Found</title></head>
|
||||
<body bgcolor="white">
|
||||
<center><h1>404 Not Found</h1></center>
|
||||
</body>
|
||||
</html>
|
||||
22
test/go/404/app.go
Normal file
22
test/go/404/app.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"nginx/unit"
|
||||
)
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
b, e := ioutil.ReadFile("404.html")
|
||||
|
||||
if e == nil {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
io.WriteString(w, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", handler)
|
||||
unit.ListenAndServe(":7080", nil)
|
||||
}
|
||||
Reference in New Issue
Block a user