Documentation
¶
Index ¶
- Variables
- func CreateAuthRequest(params interface{}, r AuthRequester, query string, token interface{}, ...) []byte
- func CreateEventQueryRequest(query string) []byte
- func CreateGetRequest(query string) []byte
- func CreateRequest(params interface{}, r Requester, query string, token interface{}, isHTTP bool) []byte
- func DecodeAccessResponse(payload []byte) (*AccessResult, *Meta, *reserr.Error)
- func DecodeChangeEvent(data json.RawMessage) (map[string]Value, error)
- func DecodeEvent(payload []byte) (json.RawMessage, error)
- func DecodeLegacyChangeEvent(data json.RawMessage) (map[string]Value, error)
- func EncodeAddEvent(d *AddEvent) json.RawMessage
- func EncodeChangeEvent(values map[string]Value) json.RawMessage
- func EncodeRemoveEvent(d *RemoveEvent) json.RawMessage
- func IsLegacyChangeEvent(data json.RawMessage) bool
- func IsValidRID(rid string, allowQuery bool) bool
- func IsValidRIDPart(part string) bool
- func MergeHeader(a, b http.Header)
- func TryDecodeLegacyNewResult(result json.RawMessage) (string, error)
- type AccessResponse
- type AccessResult
- type AddEvent
- type AuthRequest
- type AuthRequester
- type ChangeEvent
- type ConnTokenEvent
- type EventQueryEvent
- type EventQueryRequest
- type EventQueryResponse
- type EventQueryResult
- type GetRequest
- type GetResponse
- type GetResult
- type Meta
- type NewResponse
- type QueryEvent
- type RemoveEvent
- type Request
- type Requester
- type Resource
- type Response
- type SystemReset
- type SystemTokenReset
- type Value
- type ValueObject
- type ValueType
Constants ¶
This section is empty.
Variables ¶
var DeleteValue = Value{ RawMessage: json.RawMessage(`{"action":"delete"}`), Type: ValueTypeDelete, }
DeleteValue is a predeclared delete action value
Functions ¶
func CreateAuthRequest ¶
func CreateAuthRequest(params interface{}, r AuthRequester, query string, token interface{}, isHTTP bool) []byte
CreateAuthRequest creates a JSON encoded RES-service auth request
func CreateEventQueryRequest ¶
CreateEventQueryRequest creates a JSON encoded RES-service event query request
func CreateGetRequest ¶
CreateGetRequest creates a JSON encoded RES-service get request
func CreateRequest ¶
func CreateRequest(params interface{}, r Requester, query string, token interface{}, isHTTP bool) []byte
CreateRequest creates a JSON encoded RES-service request
func DecodeAccessResponse ¶
func DecodeAccessResponse(payload []byte) (*AccessResult, *Meta, *reserr.Error)
DecodeAccessResponse decodes a JSON encoded RES-service access response
func DecodeChangeEvent ¶
func DecodeChangeEvent(data json.RawMessage) (map[string]Value, error)
DecodeChangeEvent decodes a JSON encoded RES-service model change event
func DecodeEvent ¶
func DecodeEvent(payload []byte) (json.RawMessage, error)
DecodeEvent decodes a JSON encoded RES-service event
func DecodeLegacyChangeEvent ¶ added in v1.2.0
func DecodeLegacyChangeEvent(data json.RawMessage) (map[string]Value, error)
DecodeLegacyChangeEvent decodes a JSON encoded RES-service v1.0 model change event
func EncodeAddEvent ¶
func EncodeAddEvent(d *AddEvent) json.RawMessage
EncodeAddEvent creates a JSON encoded RES-service collection add event
func EncodeChangeEvent ¶ added in v1.2.0
func EncodeChangeEvent(values map[string]Value) json.RawMessage
EncodeChangeEvent creates a JSON encoded RES-service change event
func EncodeRemoveEvent ¶
func EncodeRemoveEvent(d *RemoveEvent) json.RawMessage
EncodeRemoveEvent creates a JSON encoded RES-service collection remove event
func IsLegacyChangeEvent ¶ added in v1.2.0
func IsLegacyChangeEvent(data json.RawMessage) bool
IsLegacyChangeEvent returns true if the model change event is detected as v1.0 legacy [DEPRECATED:deprecatedModelChangeEvent]
func IsValidRID ¶
IsValidRID returns true if the RID is valid, otherwise false. If allowQuery flag is false, encountering a question mark (?) will cause IsValidRID to return false.
func IsValidRIDPart ¶ added in v1.5.0
IsValidRIDPart returns true if the RID part is valid, otherwise false.
func MergeHeader ¶ added in v1.8.0
MergeHeader adds or replaces headers in a with the headers in b. It does not included protected headers, and it appends header values for "Set-Cookie".
func TryDecodeLegacyNewResult ¶ added in v1.4.0
func TryDecodeLegacyNewResult(result json.RawMessage) (string, error)
TryDecodeLegacyNewResult tries to detect legacy v1.1.1 behavior. Returns empty string and nil error when the result is not detected as legacy. [DEPRECATED:deprecatedNewCallRequest]
Types ¶
type AccessResponse ¶
type AccessResponse struct {
Result *AccessResult `json:"result"`
Error *reserr.Error `json:"error"`
Meta *Meta `json:"meta"`
}
AccessResponse represents the response of a RES-service access request https://github.com/resgateio/resgate/blob/master/docs/res-service-protocol.md#access-request
type AccessResult ¶
AccessResult represents the response result of a RES-service access request
type AddEvent ¶
AddEvent represent a RES-server collection add event https://github.com/resgateio/resgate/blob/master/docs/res-service-protocol.md#collection-add-event
func DecodeAddEvent ¶
func DecodeAddEvent(data json.RawMessage) (*AddEvent, error)
DecodeAddEvent decodes a JSON encoded RES-service collection add event
type AuthRequest ¶
type AuthRequest struct {
Request
Header http.Header `json:"header,omitempty"`
Host string `json:"host,omitempty"`
RemoteAddr string `json:"remoteAddr,omitempty"`
URI string `json:"uri,omitempty"`
}
AuthRequest represents a RES-service auth request https://github.com/resgateio/resgate/blob/master/docs/res-service-protocol.md#auth-request
type AuthRequester ¶
type AuthRequester interface {
// CID returns the connection of the requester
CID() string
// HTTPRequest returns the http.Request from requesters (upgraded) HTTP connection
HTTPRequest() *http.Request
}
AuthRequester is the connection making the auth request
type ChangeEvent ¶ added in v1.2.0
ChangeEvent represent a RES-server model change event https://github.com/resgateio/resgate/blob/master/docs/res-service-protocol.md#model-change-event
type ConnTokenEvent ¶
type ConnTokenEvent struct {
Token json.RawMessage `json:"token"`
TID string `json:"tid"`
}
ConnTokenEvent represents a RES-server connection token event https://github.com/resgateio/resgate/blob/master/docs/res-service-protocol.md#connection-token-event
func DecodeConnTokenEvent ¶
func DecodeConnTokenEvent(payload []byte) (*ConnTokenEvent, error)
DecodeConnTokenEvent decodes a JSON encoded RES-service connection token event
type EventQueryEvent ¶
type EventQueryEvent struct {
Event string `json:"event"`
Data json.RawMessage `json:"data"`
}
EventQueryEvent represents an event in the response of a RES-server query request
type EventQueryRequest ¶
type EventQueryRequest struct {
Query string `json:"query"`
}
EventQueryRequest represents a RES-service query request https://github.com/resgateio/resgate/blob/master/docs/res-service-protocol.md#query-request
type EventQueryResponse ¶
type EventQueryResponse struct {
Result *EventQueryResult `json:"result"`
Error *reserr.Error `json:"error"`
}
EventQueryResponse represent the response of a RES-service query request https://github.com/resgateio/resgate/blob/master/docs/res-service-protocol.md#query-event
type EventQueryResult ¶
type EventQueryResult struct {
Events []*EventQueryEvent `json:"events"`
Model map[string]Value `json:"model"`
Collection []Value `json:"collection"`
}
EventQueryResult represent the response's result part of a RES-service query request
func DecodeEventQueryResponse ¶
func DecodeEventQueryResponse(payload []byte) (*EventQueryResult, error)
DecodeEventQueryResponse decodes a JSON encoded RES-service event query response
type GetRequest ¶
type GetRequest struct {
Query string `json:"query,omitempty"`
}
GetRequest represents a RES-service get request https://github.com/resgateio/resgate/blob/master/docs/res-service-protocol.md#get-request
type GetResponse ¶
GetResponse represents the response of a RES-service get request
type GetResult ¶
type GetResult struct {
Model map[string]Value `json:"model"`
Collection []Value `json:"collection"`
Query string `json:"query"`
}
GetResult represent the response result of a RES-service get request
func DecodeGetResponse ¶
DecodeGetResponse decodes a JSON encoded RES-service get response
type Meta ¶ added in v1.8.0
Meta represents the meta object of a response https://github.com/resgateio/resgate/blob/master/docs/res-service-protocol.md#meta-object
func DecodeCallResponse ¶
DecodeCallResponse decodes a JSON encoded RES-service call response
func (*Meta) Canonicalize ¶ added in v1.8.0
func (m *Meta) Canonicalize()
Canonicalize updates the header keys to be in the canonicalized format.
func (*Meta) IsDirectResponseStatus ¶ added in v1.8.0
IsDirectResponseStatus returns true if the status code should not result in any subsequent request, but should be directly responded to. https://github.com/resgateio/resgate/blob/master/docs/res-service-protocol.md#status-codes
func (*Meta) IsValidStatus ¶ added in v1.8.0
IsValidStatus returns true if the meta status code is valid while establishing HTTP or WebSocket connections. https://github.com/resgateio/resgate/blob/master/docs/res-service-protocol.md#status-codes
type NewResponse ¶
NewResponse represents the response of a RES-service new call request https://github.com/resgateio/resgate/blob/master/docs/res-service-protocol.md#new-call-request
type QueryEvent ¶
type QueryEvent struct {
Subject string `json:"subject"`
}
QueryEvent represents a RES-service query event
func DecodeQueryEvent ¶
func DecodeQueryEvent(payload []byte) (*QueryEvent, error)
DecodeQueryEvent decodes a JSON encoded query event
type RemoveEvent ¶
type RemoveEvent struct {
Idx int `json:"idx"`
}
RemoveEvent represent a RES-server collection remove event https://github.com/resgateio/resgate/blob/master/docs/res-service-protocol.md#collection-remove-event
func DecodeRemoveEvent ¶
func DecodeRemoveEvent(data json.RawMessage) (*RemoveEvent, error)
DecodeRemoveEvent decodes a JSON encoded RES-service collection remove event
type Request ¶
type Request struct {
Params interface{} `json:"params,omitempty"`
Token interface{} `json:"token,omitempty"`
Query string `json:"query,omitempty"`
CID string `json:"cid"`
IsHTTP bool `json:"isHttp,omitempty"`
}
Request represents a RES-service request https://github.com/resgateio/resgate/blob/master/docs/res-service-protocol.md#requests
type Requester ¶
type Requester interface {
// CID returns the connection of the requester
CID() string
}
Requester is the connection making the request
type Resource ¶ added in v1.4.0
type Resource struct {
RID string `json:"rid"`
}
Resource represents the resource response of a RES-service call or auth request
type Response ¶
type Response struct {
Result json.RawMessage `json:"result"`
Resource *Resource `json:"resource"`
Error *reserr.Error `json:"error"`
Meta *Meta `json:"meta"`
}
Response represents a RES-service response https://github.com/resgateio/resgate/blob/master/docs/res-service-protocol.md#response
type SystemReset ¶
SystemReset represents a RES-server system reset event https://github.com/resgateio/resgate/blob/master/docs/res-service-protocol.md#system-reset-event
func DecodeSystemReset ¶
func DecodeSystemReset(data json.RawMessage) (SystemReset, error)
DecodeSystemReset decodes a JSON encoded RES-service system reset event
type SystemTokenReset ¶ added in v1.7.0
SystemTokenReset represents a RES-server system token reset event https://github.com/resgateio/resgate/blob/master/docs/res-service-protocol.md#system-token-reset-event
func DecodeSystemTokenReset ¶ added in v1.7.0
func DecodeSystemTokenReset(data json.RawMessage) (SystemTokenReset, error)
DecodeSystemTokenReset decodes a JSON encoded RES-service system token reset event
type Value ¶
type Value struct {
json.RawMessage
Type ValueType
RID string
Inner json.RawMessage
}
Value represents a RES value https://github.com/resgateio/resgate/blob/master/docs/res-protocol.md#values
func (Value) IsProper ¶ added in v1.6.0
IsProper returns true if the value's type is either a primitive, a reference, or a data value.
func (*Value) UnmarshalJSON ¶
UnmarshalJSON sets *v to the RES value represented by the JSON encoded data
type ValueObject ¶
type ValueObject struct {
RID *string `json:"rid"`
Soft bool `json:"soft"`
Action *string `json:"action"`
Data json.RawMessage `json:"data"`
}
ValueObject represents a resource reference or an action