Permalink
Browse files

refactoring

  • Loading branch information...
Kazuya Tateishi
Kazuya Tateishi committed Mar 7, 2015
1 parent 7a04ccc commit 9d328e544f8320418cd8417630457e32c36fe3cb
Showing with 387 additions and 363 deletions.
  1. +0 −4 app/api/api.rb
  2. +0 −30 app/api/v1/base.rb
  3. +0 −68 app/api/v1/comments.rb
  4. +0 −70 app/api/v1/message_boards.rb
  5. +0 −30 app/api/v2/base.rb
  6. +0 −68 app/api/v2/comments.rb
  7. +0 −68 app/api/v2/message_boards.rb
  8. +6 −0 app/apis/api/base.rb
  9. +36 −0 app/apis/api/v1/base.rb
  10. +70 −0 app/apis/api/v1/comments.rb
  11. +72 −0 app/apis/api/v1/message_boards.rb
  12. +36 −0 app/apis/api/v2/base.rb
  13. +70 −0 app/apis/api/v2/comments.rb
  14. +72 −0 app/apis/api/v2/message_boards.rb
  15. +0 −3 app/views/api/v1/comments/index.jbuilder
  16. +0 −3 app/views/api/v1/message_boards/show.jbuilder
  17. +0 −3 app/views/api/v2/comments/index.jbuilder
  18. +0 −3 app/views/api/v2/message_boards/show.jbuilder
  19. 0 app/views/{ → apis}/api/v1/comments/_comment.jbuilder
  20. +3 −0 app/views/apis/api/v1/comments/index.jbuilder
  21. 0 app/views/{ → apis}/api/v1/message_boards/_message_board.jbuilder
  22. +2 −2 app/views/{ → apis}/api/v1/message_boards/index.jbuilder
  23. +3 −0 app/views/apis/api/v1/message_boards/show.jbuilder
  24. 0 app/views/{ → apis}/api/v2/comments/_comment.jbuilder
  25. +3 −0 app/views/apis/api/v2/comments/index.jbuilder
  26. 0 app/views/{ → apis}/api/v2/message_boards/_message_board.jbuilder
  27. +2 −2 app/views/{ → apis}/api/v2/message_boards/index.jbuilder
  28. +3 −0 app/views/apis/api/v2/message_boards/show.jbuilder
  29. +3 −3 config/application.rb
  30. +1 −1 config/routes.rb
  31. +1 −1 lib/tasks/routes.rake
  32. +1 −1 spec/{ → apis}/api/v1/comments_spec.rb
  33. +1 −1 spec/{ → apis}/api/v1/message_boards_spec.rb
  34. +1 −1 spec/{ → apis}/api/v2/comments_spec.rb
  35. +1 −1 spec/{ → apis}/api/v2/message_boards_spec.rb
View

This file was deleted.

Oops, something went wrong.
View

This file was deleted.

Oops, something went wrong.
View

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
View

This file was deleted.

Oops, something went wrong.
View

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
View
@@ -0,0 +1,6 @@
module API
class Base < Grape::API
mount V1::Base
mount V2::Base
end
end
View
@@ -0,0 +1,36 @@
module API
module V1
class Base < Grape::API
format :json
default_format :json
# for Grape::Jbuilder
formatter :json, Grape::Formatter::Jbuilder
prefix :api # /apiというパスになる
version 'v1', using: :path # /api/v1というパスになる
# 例外ハンドル 404
rescue_from ActiveRecord::RecordNotFound do |e|
rack_response({ message: e.message, status: 404 }.to_json, 404)
end
# 例外ハンドル 400
rescue_from Grape::Exceptions::ValidationErrors do |e|
rack_response e.to_json, 400
end
# 例外ハンドル 500
rescue_from :all do |e|
if Rails.env.development?
raise e
else
error_response(message: "Internal server error", status: 500)
end
end
mount V1::MessageBoards
mount V1::Comments
end
end
end
Oops, something went wrong.

0 comments on commit 9d328e5

Please sign in to comment.