1.
🙅
# Gemfile
+ gem 'log-analyzer'
$ bundle exec rake log_analyzer:analyze
┏━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┓
┃ method ┃ endpoint ┃ count ┃ response_time(avg) ┃ response_time(max) ┃ response_time(min) ┃
┣━━━━━━━━╊━━━━━━━━━━━━╊━━━━━━━╊━━━━━━━━━━━━━━━━━━━━╊━━━━━━━━━━━━━━━━━━━━╊━━━━━━━━━━━━━━━━━━━━┫
┃ GET ┃ / ┃ 10 ┃ 20.5 ┃ 55 ┃ 3 ┃
┃ GET ┃ /users ┃ 5 ┃ 10.3 ┃ 30 ┃ 3 ┃
┃ GET ┃ /users/:id ┃ 3 ┃ 10 ┃ 15 ┃ 5 ┃
┃ POST ┃ /users ┃ 2 ┃ 30 ┃ 40 ┃ 20 ┃
┃ DELETE ┃ /users/:id ┃ 0 ┃ ┃ ┃ ┃
┗━━━━━━━━┻━━━━━━━━━━━━┻━━━━━━━┻━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━┛
2.
# routes.rb
scope :v1 do
resources :users, controller: 'v3/users'
end
scope :v3 do
resources :users
end
# routes.rb
scope :v1 do
resources :users, controller: 'v3/users'
end
module RenderReplaceable
def _prefixes
request_version = request.path.match(//v[0-9]//).to_s
self.class._prefixes.map do |prefix|
prefix.sub(/^api/v[0-9]//, "api#{request_version}")
end
end
end
🙆
🙆
minne の API 改善
minne の API 改善

minne の API 改善

  • 8.
  • 11.
  • 15.
    # Gemfile + gem'log-analyzer' $ bundle exec rake log_analyzer:analyze ┏━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┓ ┃ method ┃ endpoint ┃ count ┃ response_time(avg) ┃ response_time(max) ┃ response_time(min) ┃ ┣━━━━━━━━╊━━━━━━━━━━━━╊━━━━━━━╊━━━━━━━━━━━━━━━━━━━━╊━━━━━━━━━━━━━━━━━━━━╊━━━━━━━━━━━━━━━━━━━━┫ ┃ GET ┃ / ┃ 10 ┃ 20.5 ┃ 55 ┃ 3 ┃ ┃ GET ┃ /users ┃ 5 ┃ 10.3 ┃ 30 ┃ 3 ┃ ┃ GET ┃ /users/:id ┃ 3 ┃ 10 ┃ 15 ┃ 5 ┃ ┃ POST ┃ /users ┃ 2 ┃ 30 ┃ 40 ┃ 20 ┃ ┃ DELETE ┃ /users/:id ┃ 0 ┃ ┃ ┃ ┃ ┗━━━━━━━━┻━━━━━━━━━━━━┻━━━━━━━┻━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━┛
  • 18.
  • 25.
    # routes.rb scope :v1do resources :users, controller: 'v3/users' end scope :v3 do resources :users end
  • 27.
    # routes.rb scope :v1do resources :users, controller: 'v3/users' end
  • 28.
    module RenderReplaceable def _prefixes request_version= request.path.match(//v[0-9]//).to_s self.class._prefixes.map do |prefix| prefix.sub(/^api/v[0-9]//, "api#{request_version}") end end end
  • 30.