Documentation ¶
Index ¶
- type AssetGetURLHandler
- type AssetUploadURLHandler
- type DeviceRegisterHandler
- type DeviceReigsterResult
- type HomeHandler
- type LoginHandler
- type LogoutHandler
- type PasswordHandler
- type PubSubHandler
- type PushToDeviceHandler
- type PushToUserHandler
- type QueryParser
- type RecordDeleteHandler
- type RecordFetchHandler
- type RecordQueryHandler
- type RecordSaveHandler
- type RelationAddHandler
- type RelationQueryHandler
- type RelationRemoveHandler
- type SignupHandler
- type SubscriptionDeleteHandler
- type SubscriptionFetchAllHandler
- type SubscriptionFetchHandler
- type SubscriptionSaveHandler
- type UserLinkHandler
- type UserQueryHandler
- type UserUpdateHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssetGetURLHandler ¶
type AssetUploadURLHandler ¶
AssetUploadURLHandler receives and persists a file to be associated by Record.
Example curl:
curl -XPUT \ -H 'X-Skygear-API-Key: apiKey' \ -H 'Content-Type: text/plain' \ --data-binary '@file.txt' \ http://localhost:3000/files/filename
type DeviceRegisterHandler ¶
type DeviceRegisterHandler struct { }
DeviceRegisterHandler creates or updates a device and associates it to a user
Example to create a new device:
curl -X POST -H "Content-Type: application/json" \ -d @- http://localhost:3000/ <<EOF { "action": "device:register", "access_token": "some-access-token", "type": "ios", "device_token": "some-device-token" } EOF
Example to update an existing device:
curl -X POST -H "Content-Type: application/json" \ -d @- http://localhost:3000/ <<EOF { "action": "device:register", "access_token": "some-access-token", "id": "existing-device-id", "type": "ios", "device_token": "new-device-token" } EOF
type DeviceReigsterResult ¶
type DeviceReigsterResult struct {
ID string `json:"id"`
}
DeviceReigsterResult is the result put onto response.Result on successful call of DeviceRegisterHandler
type LoginHandler ¶
type LoginHandler struct { TokenStore authtoken.Store `inject:"TokenStore"` ProviderRegistry *provider.Registry `inject:"ProviderRegistry"` }
LoginHandler authenticate user with password
The user can be either identified by username or password.
curl -X POST -H "Content-Type: application/json" \ -d @- http://localhost:3000/ <<EOF
{ "action": "auth:login", "username": "rickmak", "email": "rick.mak@gmail.com", "password": "123456" }
EOF
type LogoutHandler ¶
LogoutHandler receives an access token and invalidates it
type PasswordHandler ¶
type PasswordHandler struct { }
PasswordHandler change the current user password
PasswordHandler receives three parameters:
* old_password (string, required) * password (string, required)
If user is not logged in, an 404 not found will return.
Current implementation curl -X POST -H "Content-Type: application/json" \ -d @- http://localhost:3000/ <<EOF { "action": "auth:password", "old_password": "rick.mak@gmail.com", "password": "123456" } EOF
Response return existing access toektn if not invalidate
TODO: Input accept `user_id` and `invalidate`. If `user_id` is supplied, will check authorization policy and see if existing accept `invalidate` and invaldate all existing access token. Return userInfoID with new AccessToken if the invalidate is true
type PubSubHandler ¶ added in v0.4.0
type PushToDeviceHandler ¶
type PushToUserHandler ¶
type QueryParser ¶
type QueryParser struct {
UserID string
}
QueryParser is a context for parsing raw query to skydb.Query
type RecordDeleteHandler ¶
type RecordDeleteHandler struct { HookRegistry *hook.Registry `inject:"HookRegistry"` AccessModel skydb.AccessModel `inject:"AccessModel"` }
RecordDeleteHandler is dummy implementation on delete Records
curl -X POST -H "Content-Type: application/json" \ -d @- http://localhost:3000/ <<EOF
{ "action": "record:delete", "access_token": "validToken", "database_id": "_private", "ids": ["note/EA6A3E68-90F3-49B5-B470-5FFDB7A0D4E8"] }
EOF
type RecordFetchHandler ¶
type RecordFetchHandler struct { AssetStore asset.Store `inject:"AssetStore"` AccessModel skydb.AccessModel `inject:"AccessModel"` }
RecordFetchHandler is dummy implementation on fetching Records
curl -X POST -H "Content-Type: application/json" \ -d @- http://localhost:3000/ <<EOF
{ "action": "record:fetch", "access_token": "validToken", "database_id": "_private", "ids": ["note/1004", "note/1005"] }
EOF
type RecordQueryHandler ¶
type RecordQueryHandler struct { AssetStore asset.Store `inject:"AssetStore"` AccessModel skydb.AccessModel `inject:"AccessModel"` }
RecordQueryHandler is dummy implementation on fetching Records
curl -X POST -H "Content-Type: application/json" \ -d @- http://localhost:3000/ <<EOF
{ "action": "record:query", "access_token": "validToken", "database_id": "_private", "record_type": "note", "sort": [ [{"$val": "noteOrder", "$type": "desc"}, "asc"] ] }
EOF
type RecordSaveHandler ¶
type RecordSaveHandler struct { HookRegistry *hook.Registry `inject:"HookRegistry"` AssetStore asset.Store `inject:"AssetStore"` AccessModel skydb.AccessModel `inject:"AccessModel"` }
RecordSaveHandler is dummy implementation on save/modify Records
curl -X POST -H "Content-Type: application/json" \ -d @- http://localhost:3000/ <<EOF
{ "action": "record:save", "access_token": "validToken", "database_id": "_private", "records": [{ "_id": "note/EA6A3E68-90F3-49B5-B470-5FFDB7A0D4E8", "content": "ewdsa", "_access": [{ "relation": "friend", "level": "write" }] }] }
EOF
Save with reference
curl -X POST -H "Content-Type: application/json" \ -d @- http://localhost:3000/ <<EOF
{ "action": "record:save", "database_id": "_private", "access_token": "986bee3b-8dd9-45c2-b40c-8b6ef274cf12", "records": [ { "collection": { "$type": "ref", "$id": "collection/10" }, "noteOrder": 1, "content": "hi", "_id": "note/71BAE736-E9C5-43CB-ADD1-D8633B80CAFA", "_type": "record" } ] }
EOF
type RelationAddHandler ¶
type RelationAddHandler struct { }
RelationAddHandler add current user relation
curl -X POST -H "Content-Type: application/json" \ -d @- http://localhost:3000/ <<EOF
{ "action": "relation:add", "access_token": "ACCESS_TOKEN", "name": "follow", "targets": [ "1001", "1002" ] }
EOF
{ "request_id": "REQUEST_ID", "result": [ { "id": "1001", "type": "user", "data": { "_id": "1001", "username": "user1001", "email": "user1001@skygear.io" } }, { "id": "1002", "type": "error", "data": { "type": "ResourceFetchFailure", "code": 101, "message": "failed to fetch user id = 1002" } } ] }
type RelationQueryHandler ¶
type RelationQueryHandler struct { }
RelationQueryHandler query user from current users' relation
curl -X POST -H "Content-Type: application/json" \ -d @- http://localhost:3000/ <<EOF
{ "action": "relation:query", "access_token": "ACCESS_TOKEN", "name": "follow", "direction": "outward" "limit": 2 "offset": 0 }
EOF
{ "request_id": "REQUEST_ID", "result": [ { "id": "1001", "type": "user", "data": { "_id": "1001", "username": "user1001", "email": "user1001@skygear.io" } }, { "id": "1002", "type": "user", "data": { "_id": "1002", "username": "user1002", "email": "user1001@skygear.io" } } ], "info": { "count": 2 } }
type RelationRemoveHandler ¶
type RelationRemoveHandler struct { }
RelationRemoveHandler remove a users' relation to other users
curl -X POST -H "Content-Type: application/json" \ -d @- http://localhost:3000/ <<EOF
{ "action": "relation:remove", "access_token": "ACCESS_TOKEN", "name": "follow", "targets": [ "1001", "1002" ] }
EOF
type SignupHandler ¶
type SignupHandler struct { TokenStore authtoken.Store `inject:"TokenStore"` ProviderRegistry *provider.Registry `inject:"ProviderRegistry"` }
SignupHandler creates an UserInfo with the supplied information.
SignupHandler receives three parameters:
* username (string, unique, optional) * email (string, unqiue, optional) * password (string, optional)
If both username and email is not supplied, an anonymous user is created and have user_id auto-generated. SignupHandler writes an error to response.Result if the supplied username or email collides with an existing username.
curl -X POST -H "Content-Type: application/json" \ -d @- http://localhost:3000/ <<EOF { "action": "auth:signup", "username": "rickmak", "email": "rick.mak@gmail.com", "password": "123456" } EOF
type SubscriptionDeleteHandler ¶
type SubscriptionDeleteHandler struct { }
SubscriptionDeleteHandler deletes subscriptions from the specified Database.
Example curl:
curl -X POST -H "Content-Type: application/json" \ -d @- http://localhost:3000/ <<EOF { "action": "subscription:delete", "access_token": "ACCESS_TOKEN", "database_id": "_private", "subscription_ids": ["SUBSCRIPTION_ID"] } EOF
type SubscriptionFetchAllHandler ¶
type SubscriptionFetchAllHandler struct { }
SubscriptionFetchAllHandler fetches all subscriptions of a device
curl -X POST -H "Content-Type: application/json" \ -d @- http://localhost:3000/ <<EOF { "action": "subscription:fetch_all", "access_token": "ACCESS_TOKEN", "database_id": "_private", "device_id": "DEVICE_ID" } EOF
type SubscriptionFetchHandler ¶
type SubscriptionFetchHandler struct { }
SubscriptionFetchHandler fetches subscriptions from the specified Database.
Example curl:
curl -X POST -H "Content-Type: application/json" \ -d @- http://localhost:3000/ <<EOF { "action": "subscription:fetch", "access_token": "ACCESS_TOKEN", "database_id": "_private", "device_id": "DEVICE_ID", "subscription_ids": ["SUBSCRIPTION_ID"] } EOF
type SubscriptionSaveHandler ¶
type SubscriptionSaveHandler struct { }
SubscriptionSaveHandler saves one or more subscriptions associate with a database.
Example curl:
curl -X POST -H "Content-Type: application/json" \ -d @- http://localhost:3000/ <<EOF { "action": "subscription:save", "access_token": "ACCESS_TOKEN", "database_id": "_private", "device_id": "DEVICE_ID", "subscriptions": [ { "id": "SUBSCRIPTION_ID", "notification_info": { "aps": { "alert": { "body": "BODY_TEXT", "action-loc-key": "ACTION_LOC_KEY", "loc-key": "LOC_KEY", "loc-args": ["LOC_ARGS"], "launch-image": "LAUNCH_IMAGE" }, "sound": "SOUND_NAME", "should-badge": true, "should-send-content-available": true } }, "type": "query", "query": { "record_type": "RECORD_TYPE", "predicate": {} } } ] } EOF
type UserLinkHandler ¶
UserLinkHandler lets user associate third-party accounts with the user, with third-party authentication handled by plugin.
type UserQueryHandler ¶
type UserQueryHandler struct { }
type UserUpdateHandler ¶
type UserUpdateHandler struct { }