Documentation ¶
Index ¶
- Variables
- type Error
- func BadRequest(err error) *Error
- func InternalError(err error) *Error
- func InvalidBody(field, description string) *Error
- func InvalidPath(description string) *Error
- func InvalidQuery(description string) *Error
- func InvalidResource(path riposo.Path) *Error
- func MissingResource(id, resourceName string) *Error
- func ModifiedMeanwhile(existing *Object) *Error
- type Heartbeat
- type Hello
- type Object
- func (o *Object) DecodeExtra(v interface{}) error
- func (o *Object) EncodeExtra(v interface{}) error
- func (o *Object) Get(field string) Value
- func (o *Object) MarshalJSON() ([]byte, error)
- func (o *Object) Patch(x *Object) error
- func (o *Object) UnmarshalJSON(p []byte) error
- func (o *Object) Update(x *Object)
- type Objects
- type PermissionSet
- type Resource
- type Value
Constants ¶
This section is empty.
Variables ¶
var Forbidden = &Error{ StatusCode: http.StatusForbidden, ErrCode: riposo.ErrCodeForbidden, Text: "Forbidden", Message: "This user cannot access this resource.", }
Forbidden is a standard forbidden error response.
var MethodNotAllowed = &Error{ StatusCode: http.StatusMethodNotAllowed, ErrCode: riposo.ErrCodeMethodNotAllowed, Text: "Method Not Allowed", Message: "Method not allowed on this endpoint.", }
MethodNotAllowed is a standard unauthorized error response.
var MissingAuthToken = &Error{ StatusCode: http.StatusUnauthorized, ErrCode: riposo.ErrCodeMissingAuthToken, Text: "Unauthorized", Message: "Please authenticate yourself to use this endpoint.", }
MissingAuthToken is a standard unauthorized error response.
var NotFound = &Error{ StatusCode: 404, ErrCode: riposo.ErrCodeMissingResource, Text: "Not Found", Message: "The resource you are looking for could not be found.", }
NotFound is a standard not found error response.
var NotModified = &Error{ StatusCode: http.StatusNotModified, }
NotModified is a standard not modified error response.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct { StatusCode int `json:"code"` ErrCode riposo.ErrCode `json:"errno"` Text string `json:"error"` Message string `json:"message,omitempty"` Info string `json:"info,omitempty"` Details interface{} `json:"details,omitempty"` }
Error is an error response.
func InternalError ¶
InternalError generates an Error from an internal error.
func InvalidBody ¶
InvalidBody generates an Error.
func InvalidResource ¶
InvalidResource generates a specific resource not found Error.
func MissingResource ¶
MissingResource generates an Error.
func ModifiedMeanwhile ¶
ModifiedMeanwhile generates a PreconditionFailed Error.
func (*Error) HTTPStatus ¶
HTTPStatus returns the http status code.
type Heartbeat ¶
type Heartbeat struct { Storage bool `json:"storage"` Permission bool `json:"permission"` Cache bool `json:"cache"` }
Heartbeat response object.
type Hello ¶
type Hello struct { ProjectName string `json:"project_name"` ProjectDocs string `json:"project_docs"` ProjectVersion string `json:"project_version"` HTTPAPIVersion string `json:"http_api_version"` URL string `json:"url"` EOS string `json:"eos,omitempty"` Settings struct { BatchMaxRequests int `json:"batch_max_requests"` Readonly bool `json:"readonly"` } `json:"settings"` Capabilities interface{} `json:"capabilities"` }
Hello response object.
type Object ¶
Object is a stored object.
func (*Object) DecodeExtra ¶
DecodeExtra unmarshals extra Extra into a value.
func (*Object) EncodeExtra ¶
EncodeExtra marshals v into extra Extra.
func (*Object) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface.
func (*Object) UnmarshalJSON ¶
UnmarshalJSON implements custom JSON unmarshaler.
type Objects ¶
type Objects struct {
Data []*Object `json:"data"`
}
Objects contains a slice of objects.
type PermissionSet ¶
PermissionSet contain a list of principals by type of access.
func (PermissionSet) Add ¶
func (p PermissionSet) Add(perm, principal string)
Add adds a single principal to the set.
type Resource ¶
type Resource struct { StatusCode int `json:"-"` Data *Object `json:"data,omitempty"` Permissions PermissionSet `json:"permissions,omitempty"` }
Resource contain a combination of object and permissions.
func (*Resource) HTTPStatus ¶
HTTPStatus returns the http status code.
type Value ¶
Value is a parameter/object value.
func StringValue ¶
StringValue converts a string literal to a value.
func (Value) MarshalJSON ¶
MarshalJSON implement custom JSON marshaler.
func (*Value) UnmarshalJSON ¶
UnmarshalJSON implement custom JSON unmarshaler.