diff --git a/README.md b/README.md index a7ea625..9c39f00 100644 --- a/README.md +++ b/README.md @@ -42,30 +42,30 @@ bundle exec sidekiq -C config/sidekiq.yml 1 注册 POST: http://127.0.0.1:3000/api/v1/sign_up -- 参数: - * user[email] - * user[password] - * user[password_confirmation] -- 返回结果 - -```json -{ - "user": { - "id": 10, - "name": "test5", - "email": "test5@qq.com", - "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbiI6ImU3M2YzYTljMTIxMjVkNDViNjJlNjkxNjQ4MjgyNGVmIn0.Rv_DkYEDWOIhObnTjC_8N8L-BACm8cFCOSqEgSmPUDc" + - 参数: + * user[email] + * user[password] + * user[password_confirmation] + - 返回结果 + + ```json + { + "user": { + "id": 10, + "name": "test5", + "email": "test5@qq.com", + "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbiI6ImU3M2YzYTljMTIxMjVkNDViNjJlNjkxNjQ4MjgyNGVmIn0.Rv_DkYEDWOIhObnTjC_8N8L-BACm8cFCOSqEgSmPUDc" + } } -} -``` + ``` 2 登录 POST: http://127.0.0.1:3000/api/v1/sign_in - - 参数: + - 参数: * user[email] * user[password] - - 返回结果: - - ```json + - 返回结果: + + ```json { "user": { "id": 3, @@ -74,16 +74,16 @@ bundle exec sidekiq -C config/sidekiq.yml "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbiI6IjU0MGU4OTU4ODg3ZmI1MGI5YTA5YzI4MjQ2NTZlYTRlIn0.XQBWCNRYVdDvZwuBtafCyOkNpP8FEzwRqk8AhaHlaFc" } } - ``` + ``` 3 提交分享资源 POST: http://localhost:3000/api/v1/posts - - 参数 + - 参数 * 需要登录 传Authorization header * url 网址 * type article 或者 page * description 可选 - - 返回 - + - 返回 + ``` json { "id": 32, @@ -253,33 +253,33 @@ bundle exec sidekiq -C config/sidekiq.yml 15 获取最受欢迎的文章 GET http://localhost:3000/api/v1/top -- 参数 - * 无 - -- 返回结果 - - ```json - [ - { - "viewed_times": 3, - "url": "https://github.com/strongloop/express", - "title": "strongloop/express · GitHub", - "type": "web_pages", - "processed": true, - "good_format": false, - "created_at": "2015-08-07T00:33:27.420+08:00" - }, - { - "viewed_times": 0, - "url": "https://github.com/sparklemotion/mechanize", - "title": "sparklemotion/mechanize · GitHub", - "type": "posts", - "processed": true, - "good_format": false, - "created_at": "2015-08-07T00:25:56.942+08:00" - } - ] - ``` + - 参数 + * 无 + + - 返回结果 + + ```json + [ + { + "viewed_times": 3, + "url": "https://github.com/strongloop/express", + "title": "strongloop/express · GitHub", + "type": "web_pages", + "processed": true, + "good_format": false, + "created_at": "2015-08-07T00:33:27.420+08:00" + }, + { + "viewed_times": 0, + "url": "https://github.com/sparklemotion/mechanize", + "title": "sparklemotion/mechanize · GitHub", + "type": "posts", + "processed": true, + "good_format": false, + "created_at": "2015-08-07T00:25:56.942+08:00" + } + ] + ``` #### 注意 * 注意,API返回结果中的token是利用JWT 技术加密的token,密钥是每个用户的email diff --git a/Dockerfile b/_Dockerfile similarity index 100% rename from Dockerfile rename to _Dockerfile diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 4aafc9e..ffecf4d 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -1,2 +1,8 @@ -class Api::V1::UsersController < ApplicationController +class Api::V1::UsersController < Api::V1::ApplicationController + + + def show + render json: @current_user + end + end diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb new file mode 100644 index 0000000..fa31ae2 --- /dev/null +++ b/app/serializers/user_serializer.rb @@ -0,0 +1,4 @@ +class UserSerializer < ActiveModel::Serializer + + +end \ No newline at end of file