https://github.com/ellmetha/marten-raven-middleware
Raven.cr integration for the Marten web framework.
https://github.com/ellmetha/marten-raven-middleware
crystal framework marten raven sentry sentry-client web
Last synced: 28 days ago
JSON representation
Raven.cr integration for the Marten web framework.
- Host: GitHub
- URL: https://github.com/ellmetha/marten-raven-middleware
- Owner: ellmetha
- License: mit
- Created: 2023-08-14T01:40:55.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-11T22:10:05.000Z (4 months ago)
- Last Synced: 2025-02-05T21:26:00.324Z (3 months ago)
- Topics: crystal, framework, marten, raven, sentry, sentry-client, web
- Language: Crystal
- Homepage:
- Size: 26.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Marten Raven Middleware
[](https://github.com/ellmetha/marten-raven-middleware/actions)
[](https://github.com/ellmetha/marten-raven-middleware/actions)**Marten Raven Middleware** provides a [Raven.cr](https://github.com/Sija/raven.cr) integration that allows you to get automatic error reporting for the [Marten web framework](https://github.com/martenframework/marten) by using a dedicated [middleware](https://martenframework.com/docs/handlers-and-http/middlewares).
## Installation
Simply add the following entry to your project's `shard.yml`:
```yaml
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:
```crystal
require "marten_raven_middleware"
```You should then ensure that Raven.cr is [properly configured](https://github.com/Sija/raven.cr#usage). 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:
```crystal
# config/initializers/raven.crrequire "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`](https://martenframework.com/docs/development/reference/settings#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:
```crystal
# config/settings/base.crMarten.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](https://github.com/ellmetha)) and
[contributors](https://github.com/ellmetha/marten-raven-middleware/contributors).## License
MIT. See ``LICENSE`` for more details.