REST, branch, Rails, Start, Single Sign On, Deploy, Continuous Deployment, Report Issue, ...
REST systems interface with external systems as web resources identified by Uniform Resource Identifiers (URIs)
Never ever even if looks similar
{
"id": 1,
"projects": [
{
"id": 13,
"name": "Projekt"
},
{
"id": 15,
"name": "Inny projekt"
}
],
"birthdate": "19.03.2003",
"name": "Guess Who"
}You can nest resources
but don't from day 1
class CurrentUsersController < ApplicationController
def show
# ...
end
end
# or
module Users
class CurrentsController < ApplicationController
def show
# ...
end
end
end
module Api
module V1
class PicturesController < Api::V1::BaseController
def choose
# ...
end
end
end
end
module Api
module V1
class PicturesController < Api::V1::BaseController
class Selected < Api::V1::BaseController
def create
# ...
end
end
end
end
end
class API::V3::Main::Groups < Grape::API
include API::V3::Main::Defaults
include Grape::Kaminari
resource :groups do
paginate
params do
requires :user_id, type: Integer, desc: "User ID"
end
get "user/:user_id" do
# ...
end
end
end
class API::V3::Main::Users::Groups < Grape::API
include API::V3::Main::Defaults
include Grape::Kaminari
resource :users do
params do
requires :id, type: Integer, desc: "User ID"
end
namespace ":id/groups" do
get "/" do
# like index action
end
end
end
end
module API
module V1
class Findings < Grape::API
include API::V1::Defaults
include Grape::Kaminari
resources :findings do
params do
requires :link, type: String
end
get "get_title" do
# ...
end
end
end
end
end
Title # resource
show # get_title
module Api
class CrewMembersController < ApplicationController
before_action :doorkeeper_authorize!
before_action :authenticate!
before_action :require_company
api :POST, '/crew_members/:id/resend', 'Resend a crew invitation email'
param :id, :uuid, required: true
def resend
# ...
end
end
end
Invitation # resource
create # create (and probably send) new one
# alternative e.g. for different logic
Reminder, Reinvitation, ... ?
(...) information that can be named (...)
A resource is a conceptual mapping to a set of entities, not the entity that corresponds to the mapping at any particular point in time.
http://jeromedalbert.com/how-dhh-organizes-his-rails-controllers/
https://www.thoughtworks.com/insights/blog/rest-api-design-resource-modeling
http://www.restapitutorial.com/lessons/restfulresourcenaming.html