-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathproto.go
45 lines (37 loc) · 864 Bytes
/
proto.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
package cracker
import (
"fmt"
"net/http"
)
const (
HeadError = 500
HeadOK = 200
HeadData = 201
HeadHeart = 202
HeadQuit = 203
HeadNotFound = 404
)
func WriteHTTPError(w http.ResponseWriter, message string) {
w.WriteHeader(HeadError)
fmt.Fprintf(w, "%s", message)
}
func WriteNotFoundError(w http.ResponseWriter, message string) {
w.WriteHeader(HeadNotFound)
fmt.Fprintf(w, "%s", message)
}
func WriteHTTPOK(w http.ResponseWriter, data string) {
w.WriteHeader(HeadOK)
fmt.Fprintf(w, "%s", data)
}
func WriteHTTPData(w http.ResponseWriter, data []byte) {
w.WriteHeader(HeadData)
w.Write(data)
}
func WriteHTTPQuit(w http.ResponseWriter, data string) {
w.WriteHeader(HeadQuit)
fmt.Fprintf(w, "%s", data)
}
func WriteHTTPHeart(w http.ResponseWriter, data string) {
w.WriteHeader(HeadHeart)
fmt.Fprintf(w, "%s", data)
}