-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
56 lines (46 loc) · 1.11 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
// Please see the README.md file for more information.
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
log.Printf("REQUEST | Escaped Path: %#v | Request Received: %#v", req.URL.EscapedPath(), req)
if req.URL.EscapedPath() == "/red/blue.txt" {
w.WriteHeader(404)
_, err := fmt.Fprintf(w, "This path actually doesn't exist.")
if err != nil {
return
}
return
}
if req.URL.EscapedPath() == "/red%2Fblue.txt" {
w.WriteHeader(200)
_, err := fmt.Fprintf(w, "This path exists!")
if err != nil {
return
}
return
}
if req.URL.EscapedPath() == "/normal.txt" {
w.WriteHeader(200)
_, err := fmt.Fprintf(w, "Normal file path!")
if err != nil {
return
}
return
}
_, err := fmt.Fprintf(w, "Debug: Escaped Path Recieved\n%#v\n%#v", req.URL, req.URL.EscapedPath())
if err != nil {
return
}
})
port := ":8080"
log.Println("Server starting on port", port)
err := http.ListenAndServe(port, nil)
if err != nil {
log.Fatalf("Could not start server: %s\n", err.Error())
}
}