Documentation ¶
Index ¶
- func GetCacaoHeaders(r *http.Request) (actor string, emulator string, isAdmin bool)
- func GetCacaoHeaders1(r *http.Request) (actor service.Actor, isAdmin bool)
- func JSONCacaoError(logger *log.Entry, w http.ResponseWriter, r *http.Request, err error)
- func JSONError(w http.ResponseWriter, r *http.Request, errorType string, errorMsg string, ...)
- func ReturnStatus(w http.ResponseWriter, obj interface{}, statusCode int)
- func StrictJSONDecode(data []byte, target interface{}) error
- type AcceptedResponse
- type ErrorStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCacaoHeaders ¶
GetCacaoHeaders returns headers added by Cacao Currently, this includes username, emulator, isAdmin
func GetCacaoHeaders1 ¶
GetCacaoHeaders1 returns service.Actor instead of separate strings
func JSONCacaoError ¶
JSONCacaoError writes a JSON error response, the status code is selected based on the error type.
func ReturnStatus ¶
func ReturnStatus(w http.ResponseWriter, obj interface{}, statusCode int)
ReturnStatus will return any "good" statuses
func StrictJSONDecode ¶
StrictJSONDecode will take data and a target ojbect and return an error if extra json fields are not found in the target
Types ¶
type AcceptedResponse ¶
type AcceptedResponse struct { ID string `json:"id,omitempty"` TransactionID common.TransactionID `json:"tid,omitempty"` Timestamp time.Time `json:"timestamp"` }
AcceptedResponse is used to indicate that a request has been accepted.
func NewAcceptedResponse ¶
func NewAcceptedResponse(id common.ID, transactionID common.TransactionID) *AcceptedResponse
NewAcceptedResponse creates a new response indicating that a request has been accepted.
func NewAcceptedResponseWithStrID ¶
func NewAcceptedResponseWithStrID(id string, transactionID common.TransactionID) *AcceptedResponse
NewAcceptedResponseWithStrID creates a new response indicating that a request has been accepted.
type ErrorStatus ¶
type ErrorStatus struct { Actor string `json:"actor"` Timestamp string `json:"timestamp"` ErrorType string `json:"error"` Message string `json:"message"` Path string `json:"path"` Verb string `json:"verb"` }
ErrorStatus is the struct/json object that is marshalled for every error response per CACAO's openapi spec