mirror of
https://gitee.com/goploy/goploy.git
synced 2024-12-02 12:10:05 +08:00
30 lines
519 B
Go
30 lines
519 B
Go
package response
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
type JSON struct {
|
|
Code int `json:"code"`
|
|
Message string `json:"message"`
|
|
Data interface{} `json:"data"`
|
|
}
|
|
|
|
// response code
|
|
const (
|
|
Pass = 0
|
|
Deny = 1
|
|
Error = 2
|
|
AccountDisabled = 10000
|
|
IllegalRequest = 10001
|
|
NamespaceInvalid = 10002
|
|
IllegalParam = 10003
|
|
LoginExpired = 10086
|
|
)
|
|
|
|
//JSON response
|
|
func (j JSON) Write(w http.ResponseWriter) error {
|
|
return json.NewEncoder(w).Encode(j)
|
|
}
|