marten-raven-middleware v0.1.0
Marten Raven Middleware
Marten Raven Middleware provides a Raven.cr integration that allows you to get automatic error reporting for the Marten web framework by using a dedicated middleware.
Installation
Simply add the following entry to your project's shard.yml
:
dependencies:
marten_raven_middleware:
github: ellmetha/marten-raven-middleware
And run shards install
afterward.
Configuration
First, add the following requirement to your project's src/project.cr
file:
require "marten_raven_middleware"
You should then ensure that Raven.cr is properly configured. In a Marten project, you'll likely create a config/initializers/raven.cr
initializer where you require and configure the Raven client for your project. For example:
# config/initializers/raven.cr
require "raven"
Raven.configure do |config|
config.dsn = "your_dsn"
end
To get automatic error reporting for your project, you then need to add the Raven::Marten::Middleware
middleware class to the middleware
Marten setting. Ideally, this middleware should be placed near the beginning of the middleware
array to ensure that it can catch any errors raised by the following middlewares in the stack. For example:
# config/settings/base.cr
Marten.configure do |config|
config.middleware = [
Raven::Marten::Middleware,
# Other middlewares...
Marten::Middleware::GZip,
Marten::Middleware::XFrameOptions,
Marten::Middleware::StrictTransportSecurity,
]
end
That's it! From now on every exception that is raised by your handlers and middlewares will be reported to Sentry automatically.
Authors
Morgan Aubert (@ellmetha) and contributors.
License
MIT. See LICENSE
for more details.
marten-raven-middleware
- 1
- 0
- 0
- 1
- 3
- 2 months ago
- August 14, 2023
MIT License
Fri, 27 Dec 2024 07:06:43 GMT