Skip to content

Commit

Permalink
Update Grape app to Ruby gem 4
Browse files Browse the repository at this point in the history
Update to the new integration loader mechanism.
  • Loading branch information
tombruijn committed Aug 23, 2024
1 parent a55bf87 commit 98d9d60
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ruby/grape/app/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: /integration
specs:
appsignal (3.9.1)
appsignal (4.0.0)
rack

GEM
Expand Down
3 changes: 1 addition & 2 deletions ruby/grape/app/api.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require "grape"
require "appsignal/integrations/grape"

# In memory database for posts
class Posts
Expand All @@ -24,7 +23,7 @@ def find_by_id(id)

module MyApp
class BaseAPI < Grape::API
insert_before Grape::Middleware::Error, Appsignal::Grape::Middleware
insert_before Grape::Middleware::Error, Appsignal::Rack::GrapeMiddleware
end

module PostsAPI
Expand Down
11 changes: 4 additions & 7 deletions ruby/grape/app/config.ru
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
require "appsignal"
require "grape"

Appsignal.config = Appsignal::Config.new(
Dir.pwd,
ENV.fetch("RACK_ENV", "development")
)
use ::Rack::Events, [Appsignal::Rack::EventHandler.new]

Appsignal.load(:grape)
Appsignal.start
Appsignal.start_logger

require_relative "api"

use ::Rack::Events, [Appsignal::Rack::EventHandler.new]

MyApp::API.compile!
run MyApp::API

0 comments on commit 98d9d60

Please sign in to comment.