34 lines
687 B
Go
34 lines
687 B
Go
package http
|
|
|
|
type Response interface {
|
|
SetCode(int)
|
|
SetReason(string)
|
|
SetData(any)
|
|
}
|
|
|
|
type response struct {
|
|
Code int `json:"code,omitempty" xml:"code,omitempty" yaml:"code,omitempty"`
|
|
Reason string `json:"reason,omitempty" xml:"reason,omitempty" yaml:"reason,omitempty"`
|
|
Data any `json:"data,omitempty" xml:"data,omitempty" yaml:"data,omitempty"`
|
|
}
|
|
|
|
func (r *response) SetCode(code int) {
|
|
r.Code = code
|
|
}
|
|
|
|
func (r *response) SetReason(reason string) {
|
|
r.Reason = reason
|
|
}
|
|
|
|
func (r *response) SetData(data any) {
|
|
r.Data = data
|
|
}
|
|
|
|
func newResponse(code int, reason string, data any) Response {
|
|
return &response{
|
|
Code: code,
|
|
Reason: reason,
|
|
Data: data,
|
|
}
|
|
}
|