mirror of
https://gitee.com/goploy/goploy.git
synced 2024-11-29 18:57:59 +08:00
31 lines
523 B
Go
31 lines
523 B
Go
package core
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
//Response struct
|
|
type Response 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
|
|
LoginExpired = 10086
|
|
)
|
|
|
|
//JSON response
|
|
func (r *Response) JSON(w http.ResponseWriter) {
|
|
if err := json.NewEncoder(w).Encode(r); err != nil {
|
|
Log(ERROR, err.Error())
|
|
}
|
|
}
|