package httpapi

type APIError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type Envelope struct {
	OK    bool        `json:"ok"`
	Data  interface{} `json:"data"`
	Error *APIError   `json:"error"`
}

func OK(data interface{}) Envelope {
	return Envelope{OK: true, Data: data, Error: nil}
}

func Fail(code, message string) Envelope {
	return Envelope{
		OK:    false,
		Data:  nil,
		Error: &APIError{Code: code, Message: message},
	}
}
