-
-
Notifications
You must be signed in to change notification settings - Fork 560
/
funcs.go
78 lines (75 loc) Β· 4.31 KB
/
funcs.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package codegen
import (
"fmt"
"net/http"
)
// statusCodeToHTTPConst produces the standard name for the given HTTP status
// code. If no standard name exists then the string consisting of the code
// integer value is returned.
func statusCodeToHTTPConst(statusCode int) string {
if v, ok := statusCodeToConst[statusCode]; ok {
return fmt.Sprintf("http.%s", v)
}
return fmt.Sprintf("%d", statusCode)
}
var statusCodeToConst = map[int]string{
http.StatusContinue: "StatusContinue",
http.StatusSwitchingProtocols: "StatusSwitchingProtocols",
http.StatusProcessing: "StatusProcessing",
http.StatusOK: "StatusOK",
http.StatusCreated: "StatusCreated",
http.StatusAccepted: "StatusAccepted",
http.StatusNonAuthoritativeInfo: "StatusNonAuthoritativeInfo",
http.StatusNoContent: "StatusNoContent",
http.StatusResetContent: "StatusResetContent",
http.StatusPartialContent: "StatusPartialContent",
http.StatusMultiStatus: "StatusMultiStatus",
http.StatusAlreadyReported: "StatusAlreadyReported",
http.StatusIMUsed: "StatusIMUsed",
http.StatusMultipleChoices: "StatusMultipleChoices",
http.StatusMovedPermanently: "StatusMovedPermanently",
http.StatusFound: "StatusFound",
http.StatusSeeOther: "StatusSeeOther",
http.StatusNotModified: "StatusNotModified",
http.StatusUseProxy: "StatusUseProxy",
http.StatusTemporaryRedirect: "StatusTemporaryRedirect",
http.StatusPermanentRedirect: "StatusPermanentRedirect",
http.StatusBadRequest: "StatusBadRequest",
http.StatusUnauthorized: "StatusUnauthorized",
http.StatusPaymentRequired: "StatusPaymentRequired",
http.StatusForbidden: "StatusForbidden",
http.StatusNotFound: "StatusNotFound",
http.StatusMethodNotAllowed: "StatusMethodNotAllowed",
http.StatusNotAcceptable: "StatusNotAcceptable",
http.StatusProxyAuthRequired: "StatusProxyAuthRequired",
http.StatusRequestTimeout: "StatusRequestTimeout",
http.StatusConflict: "StatusConflict",
http.StatusGone: "StatusGone",
http.StatusLengthRequired: "StatusLengthRequired",
http.StatusPreconditionFailed: "StatusPreconditionFailed",
http.StatusRequestEntityTooLarge: "StatusRequestEntityTooLarge",
http.StatusRequestURITooLong: "StatusRequestURITooLong",
http.StatusUnsupportedMediaType: "StatusUnsupportedMediaType",
http.StatusRequestedRangeNotSatisfiable: "StatusRequestedRangeNotSatisfiable",
http.StatusExpectationFailed: "StatusExpectationFailed",
http.StatusTeapot: "StatusTeapot",
http.StatusUnprocessableEntity: "StatusUnprocessableEntity",
http.StatusLocked: "StatusLocked",
http.StatusFailedDependency: "StatusFailedDependency",
http.StatusUpgradeRequired: "StatusUpgradeRequired",
http.StatusPreconditionRequired: "StatusPreconditionRequired",
http.StatusTooManyRequests: "StatusTooManyRequests",
http.StatusRequestHeaderFieldsTooLarge: "StatusRequestHeaderFieldsTooLarge",
http.StatusUnavailableForLegalReasons: "StatusUnavailableForLegalReasons",
http.StatusInternalServerError: "StatusInternalServerError",
http.StatusNotImplemented: "StatusNotImplemented",
http.StatusBadGateway: "StatusBadGateway",
http.StatusServiceUnavailable: "StatusServiceUnavailable",
http.StatusGatewayTimeout: "StatusGatewayTimeout",
http.StatusHTTPVersionNotSupported: "StatusHTTPVersionNotSupported",
http.StatusVariantAlsoNegotiates: "StatusVariantAlsoNegotiates",
http.StatusInsufficientStorage: "StatusInsufficientStorage",
http.StatusLoopDetected: "StatusLoopDetected",
http.StatusNotExtended: "StatusNotExtended",
http.StatusNetworkAuthenticationRequired: "StatusNetworkAuthenticationRequired",
}