json message 집합 이동
This commit is contained in:
parent
a9a06fd142
commit
d9d96073e8
|
@ -1,55 +0,0 @@
|
|||
package http
|
||||
|
||||
const (
|
||||
// 200
|
||||
JsonOK ResponseMessage = "{\"message\":\"OK\"}"
|
||||
JsonPartialContent = "{\"message\":\"Partial Content\"}"
|
||||
|
||||
// 300
|
||||
JsonMovedPermanently ResponseMessage = "{\"message\":\"Moved Permanently\"}"
|
||||
JsonFound = "{\"message\":\"Found\"}"
|
||||
JsonSeeOther = "{\"message\":\"See Other\"}"
|
||||
JsonTemporaryRedirect = "{\"message\":\"Temporary Redirect\"}"
|
||||
JsonPermanentRedirect = "{\"message\":\"Permanent Redirect\"}"
|
||||
JsonUnauthorized = "{\"message\":\"Unauthorized\"}"
|
||||
JsonPaymentRequired = "{\"message\":\"Payment Required\"}"
|
||||
|
||||
// 400
|
||||
JsonBadRequest ResponseMessage = "{\"message\":\"Bad Request\"}"
|
||||
JsonForbidden = "{\"message\":\"Forbidden\"}"
|
||||
JsonNotFound = "{\"message\":\"Not Found\"}"
|
||||
JsonMethodNotAllowed = "{\"message\":\"Method Not Allowed\"}"
|
||||
JsonNotAcceptable = "{\"message\":\"Not Acceptable\"}"
|
||||
JsonRequestTimeout = "{\"message\":\"Request Timeout\"}"
|
||||
JsonConflict = "{\"message\":\"Conflict\"}"
|
||||
JsonGone = "{\"message\":\"Gone\"}"
|
||||
JsonPreconditionFailed = "{\"message\":\"Precondition Failed\"}"
|
||||
JsonRequestEntityTooLarge = "{\"message\":\"Request Entity Too Large\"}"
|
||||
JsonRequestURITooLong = "{\"message\":\"Request URI Too Long\"}"
|
||||
JsonUnsupportedMediaType = "{\"message\":\"Unsupported Media Type\"}"
|
||||
JsonUpgradeRequired = "{\"message\":\"Upgrade Required\"}"
|
||||
JsonPreconditionRequired = "{\"message\":\"Precondition Required\"}"
|
||||
JsonTooManyRequests = "{\"message\":\"Too Many Requests\"}"
|
||||
JsonRequestHeaderFieldsTooLarge = "{\"message\":\"Request Header Fields Too Large\"}"
|
||||
JsonUnavailableForLegalReasons = "{\"message\":\"Unavailable For Legal Reasons\"}"
|
||||
|
||||
// 500
|
||||
JsonInternalServerError ResponseMessage = "{\"message\":\"Internal Server Error\"}"
|
||||
JsonNotImplemented = "{\"message\":\"Not Implemented\"}"
|
||||
JsonBadGateway = "{\"message\":\"Bad Gateway\"}"
|
||||
JsonServiceUnavailable = "{\"message\":\"Service Unavailable\"}"
|
||||
JsonGatewayTimeout = "{\"message\":\"Gateway Timeout\"}"
|
||||
JsonHTTPVersionNotSupported = "{\"message\":\"HTTP Version Not Supported\"}"
|
||||
JsonInsufficientStorage = "{\"message\":\"Insufficient Storage\"}"
|
||||
JsonLoopDetected = "{\"message\":\"Loop Detected\"}"
|
||||
)
|
||||
|
||||
var (
|
||||
JsonContentType = []string{"application/json; charset=utf-8"}
|
||||
)
|
||||
|
||||
type ResponseMessage string
|
||||
|
||||
func (rm ResponseMessage) MarshalJSON() ([]byte, error) {
|
||||
return []byte(rm), nil
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package json
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var (
|
||||
// 200
|
||||
ResponseOK = ResponseMessage(http.StatusText(http.StatusOK))
|
||||
ResponsePartialContent = ResponseMessage(http.StatusText(http.StatusPartialContent))
|
||||
|
||||
// 300
|
||||
ResponseMovedPermanently = ResponseMessage(http.StatusText(http.StatusMovedPermanently))
|
||||
ResponseFound = ResponseMessage(http.StatusText(http.StatusFound))
|
||||
ResponseSeeOther = ResponseMessage(http.StatusText(http.StatusSeeOther))
|
||||
ResponseTemporaryRedirect = ResponseMessage(http.StatusText(http.StatusTemporaryRedirect))
|
||||
ResponsePermanentRedirect = ResponseMessage(http.StatusText(http.StatusPermanentRedirect))
|
||||
ResponseUnauthorized = ResponseMessage(http.StatusText(http.StatusUnauthorized))
|
||||
ResponsePaymentRequired = ResponseMessage(http.StatusText(http.StatusPaymentRequired))
|
||||
|
||||
// 400
|
||||
ResponseBadRequest = ResponseMessage(http.StatusText(http.StatusBadRequest))
|
||||
ResponseForbidden = ResponseMessage(http.StatusText(http.StatusForbidden))
|
||||
ResponseNotFound = ResponseMessage(http.StatusText(http.StatusNotFound))
|
||||
ResponseMethodNotAllowed = ResponseMessage(http.StatusText(http.StatusMethodNotAllowed))
|
||||
ResponseNotAcceptable = ResponseMessage(http.StatusText(http.StatusNotAcceptable))
|
||||
ResponseRequestTimeout = ResponseMessage(http.StatusText(http.StatusRequestTimeout))
|
||||
ResponseConflict = ResponseMessage(http.StatusText(http.StatusConflict))
|
||||
ResponseGone = ResponseMessage(http.StatusText(http.StatusGone))
|
||||
ResponsePreconditionFailed = ResponseMessage(http.StatusText(http.StatusPreconditionFailed))
|
||||
ResponseRequestEntityTooLarge = ResponseMessage(http.StatusText(http.StatusRequestEntityTooLarge))
|
||||
ResponseRequestURITooLong = ResponseMessage(http.StatusText(http.StatusRequestURITooLong))
|
||||
ResponseUnsupportedMediaType = ResponseMessage(http.StatusText(http.StatusUnsupportedMediaType))
|
||||
ResponseUpgradeRequired = ResponseMessage(http.StatusText(http.StatusUpgradeRequired))
|
||||
ResponsePreconditionRequired = ResponseMessage(http.StatusText(http.StatusPreconditionRequired))
|
||||
ResponseTooManyRequests = ResponseMessage(http.StatusText(http.StatusTooManyRequests))
|
||||
ResponseRequestHeaderFieldsTooLarge = ResponseMessage(http.StatusText(http.StatusRequestHeaderFieldsTooLarge))
|
||||
ResponseUnavailableForLegalReasons = ResponseMessage(http.StatusText(http.StatusUnavailableForLegalReasons))
|
||||
|
||||
// 500
|
||||
ResponseInternalServerError = ResponseMessage(http.StatusText(http.StatusInternalServerError))
|
||||
ResponseNotImplemented = ResponseMessage(http.StatusText(http.StatusNotImplemented))
|
||||
ResponseBadGateway = ResponseMessage(http.StatusText(http.StatusBadGateway))
|
||||
ResponseServiceUnavailable = ResponseMessage(http.StatusText(http.StatusServiceUnavailable))
|
||||
ResponseGatewayTimeout = ResponseMessage(http.StatusText(http.StatusGatewayTimeout))
|
||||
ResponseHTTPVersionNotSupported = ResponseMessage(http.StatusText(http.StatusHTTPVersionNotSupported))
|
||||
ResponseInsufficientStorage = ResponseMessage(http.StatusText(http.StatusInsufficientStorage))
|
||||
)
|
||||
|
||||
type ResponseMessage string
|
||||
|
||||
const (
|
||||
responseMessagePayloadStart = `{"message":"`
|
||||
responseMessagePayloadEnd = `"}`
|
||||
)
|
||||
|
||||
func (rm ResponseMessage) MarshalJSON() ([]byte, error) {
|
||||
buf := bytes.Buffer{}
|
||||
buf.WriteString(responseMessagePayloadStart)
|
||||
buf.WriteString(string(rm))
|
||||
buf.WriteString(responseMessagePayloadEnd)
|
||||
|
||||
return buf.Bytes(), nil
|
||||
}
|
Reference in New Issue