|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | | -module API |
4 | | - class Root < Grape::API |
5 | | - format :json |
6 | | - default_format :json |
7 | | - content_type :json, 'application/json' |
8 | | - prefix :api |
| 3 | +module GrapeApiBoilerplate |
| 4 | + module Api |
| 5 | + class Root < Grape::API |
| 6 | + format :json |
| 7 | + default_format :json |
| 8 | + content_type :json, 'application/json' |
| 9 | + prefix :api |
9 | 10 |
|
10 | | - rescue_from :grape_exceptions |
| 11 | + rescue_from :grape_exceptions |
11 | 12 |
|
12 | | - # Logging |
13 | | - insert_before Grape::Middleware::Error, GrapeLogging::Middleware::RequestLogger, |
14 | | - { |
15 | | - logger:, |
16 | | - formatter: GrapeLogging::Formatters::Json.new, |
17 | | - include: [GrapeLogging::Loggers::FilterParameters.new([:password])] |
18 | | - } |
| 13 | + # Logging |
| 14 | + insert_before Grape::Middleware::Error, GrapeLogging::Middleware::RequestLogger, |
| 15 | + { |
| 16 | + logger:, |
| 17 | + formatter: GrapeLogging::Formatters::Json.new, |
| 18 | + include: [GrapeLogging::Loggers::FilterParameters.new([:password])] |
| 19 | + } |
19 | 20 |
|
20 | | - # Helpers |
21 | | - helpers do |
22 | | - include Helpers |
23 | | - end |
| 21 | + # Helpers |
| 22 | + helpers do |
| 23 | + include Helpers |
| 24 | + end |
24 | 25 |
|
25 | | - # Routes |
26 | | - mount GrapeApiBoilerplate::Api::Endpoints::Session |
27 | | - mount GrapeApiBoilerplate::Api::Endpoints::V1::HelloWorldEndpoint |
28 | | - mount GrapeApiBoilerplate::Api::Endpoints::V1::WidgetEndpoint |
| 26 | + # Routes |
| 27 | + mount GrapeApiBoilerplate::Api::Endpoints::Session |
| 28 | + mount GrapeApiBoilerplate::Api::Endpoints::V1::HelloWorldEndpoint |
| 29 | + mount GrapeApiBoilerplate::Api::Endpoints::V1::WidgetEndpoint |
29 | 30 |
|
30 | | - add_swagger_documentation \ |
31 | | - info: { |
32 | | - title: 'Grape Boilerplate', |
33 | | - description: 'A full-featured API boilerplate to get you started with the Grape framework.' |
34 | | - } |
| 31 | + add_swagger_documentation \ |
| 32 | + info: { |
| 33 | + title: 'Grape Boilerplate', |
| 34 | + description: 'A full-featured API boilerplate to get you started with the Grape framework.' |
| 35 | + } |
35 | 36 |
|
36 | | - # Handle 404s |
37 | | - route :any, '*path' do |
38 | | - error!({ message: 'resource does not exist' }, 404) |
| 37 | + # Handle 404s |
| 38 | + route :any, '*path' do |
| 39 | + error!({ message: 'resource does not exist' }, 404) |
| 40 | + end |
39 | 41 | end |
40 | 42 | end |
41 | 43 | end |
0 commit comments