Documentation
¶
Index ¶
- func AssetGetURLHandler(payload *router.Payload, response *router.Response)
- func AssetUploadURLHandler(payload *router.Payload, response *router.Response)
- func DeviceRegisterHandler(rpayload *router.Payload, response *router.Response)
- func HomeHandler(playload *router.Payload, response *router.Response)
- func LoginHandler(payload *router.Payload, response *router.Response)
- func LogoutHandler(payload *router.Payload, response *router.Response)
- func NewPubSubHandler(ws *pubsub.WsPubSub) router.Handler
- func PasswordHandler(payload *router.Payload, response *router.Response)
- func PushToDeviceHandler(rpayload *router.Payload, response *router.Response)
- func PushToUserHandler(rpayload *router.Payload, response *router.Response)
- func RecordDeleteHandler(payload *router.Payload, response *router.Response)
- func RecordFetchHandler(payload *router.Payload, response *router.Response)
- func RecordQueryHandler(payload *router.Payload, response *router.Response)
- func RecordSaveHandler(payload *router.Payload, response *router.Response)
- func RelationAddHandler(rpayload *router.Payload, response *router.Response)
- func RelationQueryHandler(rpayload *router.Payload, response *router.Response)
- func RelationRemoveHandler(rpayload *router.Payload, response *router.Response)
- func SignupHandler(payload *router.Payload, response *router.Response)
- func SubscriptionDeleteHandler(rpayload *router.Payload, response *router.Response)
- func SubscriptionFetchAllHandler(rpayload *router.Payload, response *router.Response)
- func SubscriptionFetchHandler(rpayload *router.Payload, response *router.Response)
- func SubscriptionSaveHandler(rpayload *router.Payload, response *router.Response)
- func UserLinkHandler(payload *router.Payload, response *router.Response)
- func UserQueryHandler(payload *router.Payload, response *router.Response)
- func UserUpdateHandler(payload *router.Payload, response *router.Response)
- type DeviceReigsterResult
- type QueryParser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssetGetURLHandler ¶
func 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
func DeviceRegisterHandler ¶
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
func HomeHandler ¶
HomeHandler temp landing. FIXME
func LoginHandler ¶
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
func LogoutHandler ¶
LogoutHandler receives an access token and invalidates it
func PasswordHandler ¶
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
func PushToDeviceHandler ¶
func PushToUserHandler ¶
func RecordDeleteHandler ¶
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
func RecordFetchHandler ¶
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
func RecordQueryHandler ¶
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
func RecordSaveHandler ¶
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
func RelationAddHandler ¶
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"
}
}
]
}
func RelationQueryHandler ¶
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
}
}
func RelationRemoveHandler ¶
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
func SignupHandler ¶
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
func SubscriptionDeleteHandler ¶
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
func SubscriptionFetchAllHandler ¶
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
func SubscriptionFetchHandler ¶
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
func SubscriptionSaveHandler ¶
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
func UserLinkHandler ¶
UserLinkHandler lets user associate third-party accounts with the user, with third-party authentication handled by plugin.
Types ¶
type DeviceReigsterResult ¶
type DeviceReigsterResult struct {
ID string `json:"id"`
}
DeviceReigsterResult is the result put onto response.Result on successful call of DeviceRegisterHandler
type QueryParser ¶
type QueryParser struct {
UserID string
}
QueryParser is a context for parsing raw query to skydb.Query