vitals 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +23 -3
- data/lib/vitals/utils.rb +4 -3
- data/lib/vitals/version.rb +1 -1
- data/lib/vitals.rb +13 -0
- data/vitals.gemspec +1 -1
- metadata +2 -184
- data/integration/multiverse/grape-on-rack/.gitignore +0 -7
- data/integration/multiverse/grape-on-rack/.rspec +0 -2
- data/integration/multiverse/grape-on-rack/.rubocop.yml +0 -2
- data/integration/multiverse/grape-on-rack/.rubocop_todo.yml +0 -50
- data/integration/multiverse/grape-on-rack/.travis.yml +0 -12
- data/integration/multiverse/grape-on-rack/Gemfile +0 -28
- data/integration/multiverse/grape-on-rack/Gemfile.lock +0 -187
- data/integration/multiverse/grape-on-rack/Guardfile +0 -8
- data/integration/multiverse/grape-on-rack/LICENSE +0 -21
- data/integration/multiverse/grape-on-rack/README.md +0 -88
- data/integration/multiverse/grape-on-rack/Rakefile +0 -27
- data/integration/multiverse/grape-on-rack/api/content_type.rb +0 -18
- data/integration/multiverse/grape-on-rack/api/entities.rb +0 -28
- data/integration/multiverse/grape-on-rack/api/get_json.rb +0 -24
- data/integration/multiverse/grape-on-rack/api/header_versioning.rb +0 -9
- data/integration/multiverse/grape-on-rack/api/path_versioning.rb +0 -9
- data/integration/multiverse/grape-on-rack/api/ping.rb +0 -8
- data/integration/multiverse/grape-on-rack/api/post_json.rb +0 -11
- data/integration/multiverse/grape-on-rack/api/post_put.rb +0 -24
- data/integration/multiverse/grape-on-rack/api/rescue_from.rb +0 -11
- data/integration/multiverse/grape-on-rack/api/upload_file.rb +0 -22
- data/integration/multiverse/grape-on-rack/api/wrap_response.rb +0 -14
- data/integration/multiverse/grape-on-rack/api/wrap_response_decorator.rb +0 -15
- data/integration/multiverse/grape-on-rack/app/acme_app.rb +0 -49
- data/integration/multiverse/grape-on-rack/app/api.rb +0 -18
- data/integration/multiverse/grape-on-rack/config/application.rb +0 -23
- data/integration/multiverse/grape-on-rack/config/boot.rb +0 -2
- data/integration/multiverse/grape-on-rack/config/environment.rb +0 -3
- data/integration/multiverse/grape-on-rack/config/newrelic.yml +0 -255
- data/integration/multiverse/grape-on-rack/config.ru +0 -11
- data/integration/multiverse/grape-on-rack/public/errors/404.html +0 -15
- data/integration/multiverse/grape-on-rack/public/errors/500.html +0 -15
- data/integration/multiverse/grape-on-rack/public/images/index.html +0 -1
- data/integration/multiverse/grape-on-rack/public/images/rack-logo.png +0 -0
- data/integration/multiverse/grape-on-rack/public/index.html +0 -23
- data/integration/multiverse/grape-on-rack/public/scripts/jquery-1.7.1.min.js +0 -4
- data/integration/multiverse/grape-on-rack/public/scripts/ring.js +0 -17
- data/integration/multiverse/grape-on-rack/spec/api/post_put_spec.rb +0 -21
- data/integration/multiverse/grape-on-rack/spec/fixtures/grape_logo.png +0 -0
- data/integration/multiverse/grape-on-rack/spec/spec_helper.rb +0 -24
- data/integration/multiverse/grape-on-rails/.gitignore +0 -16
- data/integration/multiverse/grape-on-rails/.rspec +0 -2
- data/integration/multiverse/grape-on-rails/.rubocop.yml +0 -6
- data/integration/multiverse/grape-on-rails/.rubocop_todo.yml +0 -33
- data/integration/multiverse/grape-on-rails/.travis.yml +0 -17
- data/integration/multiverse/grape-on-rails/Gemfile +0 -22
- data/integration/multiverse/grape-on-rails/Gemfile.lock +0 -238
- data/integration/multiverse/grape-on-rails/README.md +0 -29
- data/integration/multiverse/grape-on-rails/Rakefile +0 -16
- data/integration/multiverse/grape-on-rails/app/api/acme/ping.rb +0 -8
- data/integration/multiverse/grape-on-rails/app/api/acme/post.rb +0 -10
- data/integration/multiverse/grape-on-rails/app/api/acme/protected.rb +0 -13
- data/integration/multiverse/grape-on-rails/app/api/acme/raise.rb +0 -8
- data/integration/multiverse/grape-on-rails/app/api/api.rb +0 -8
- data/integration/multiverse/grape-on-rails/app/assets/images/rails.png +0 -0
- data/integration/multiverse/grape-on-rails/app/assets/javascripts/application.js +0 -15
- data/integration/multiverse/grape-on-rails/app/assets/javascripts/welcome.js.coffee +0 -3
- data/integration/multiverse/grape-on-rails/app/assets/stylesheets/application.css +0 -13
- data/integration/multiverse/grape-on-rails/app/assets/stylesheets/welcome.css.scss +0 -3
- data/integration/multiverse/grape-on-rails/app/controllers/application_controller.rb +0 -3
- data/integration/multiverse/grape-on-rails/app/controllers/welcome_controller.rb +0 -4
- data/integration/multiverse/grape-on-rails/app/helpers/application_helper.rb +0 -2
- data/integration/multiverse/grape-on-rails/app/helpers/welcome_helper.rb +0 -2
- data/integration/multiverse/grape-on-rails/app/mailers/.gitkeep +0 -0
- data/integration/multiverse/grape-on-rails/app/models/.gitkeep +0 -0
- data/integration/multiverse/grape-on-rails/app/views/layouts/application.html.erb +0 -14
- data/integration/multiverse/grape-on-rails/app/views/welcome/index.html.erb +0 -6
- data/integration/multiverse/grape-on-rails/bin/bundle +0 -3
- data/integration/multiverse/grape-on-rails/bin/rails +0 -4
- data/integration/multiverse/grape-on-rails/bin/rake +0 -4
- data/integration/multiverse/grape-on-rails/config/application.rb +0 -65
- data/integration/multiverse/grape-on-rails/config/boot.rb +0 -6
- data/integration/multiverse/grape-on-rails/config/database.travis.yml +0 -4
- data/integration/multiverse/grape-on-rails/config/database.yml +0 -16
- data/integration/multiverse/grape-on-rails/config/environment.rb +0 -5
- data/integration/multiverse/grape-on-rails/config/environments/development.rb +0 -29
- data/integration/multiverse/grape-on-rails/config/environments/production.rb +0 -65
- data/integration/multiverse/grape-on-rails/config/environments/test.rb +0 -33
- data/integration/multiverse/grape-on-rails/config/initializers/backtrace_silencers.rb +0 -7
- data/integration/multiverse/grape-on-rails/config/initializers/inflections.rb +0 -15
- data/integration/multiverse/grape-on-rails/config/initializers/mime_types.rb +0 -5
- data/integration/multiverse/grape-on-rails/config/initializers/reload_api.rb +0 -13
- data/integration/multiverse/grape-on-rails/config/initializers/secret_token.rb +0 -1
- data/integration/multiverse/grape-on-rails/config/initializers/session_store.rb +0 -8
- data/integration/multiverse/grape-on-rails/config/initializers/vitals.rb +0 -8
- data/integration/multiverse/grape-on-rails/config/initializers/wrap_parameters.rb +0 -14
- data/integration/multiverse/grape-on-rails/config/locales/en.yml +0 -5
- data/integration/multiverse/grape-on-rails/config/routes.rb +0 -5
- data/integration/multiverse/grape-on-rails/config.ru +0 -4
- data/integration/multiverse/grape-on-rails/db/schema.rb +0 -16
- data/integration/multiverse/grape-on-rails/db/seeds.rb +0 -7
- data/integration/multiverse/grape-on-rails/doc/README_FOR_APP +0 -2
- data/integration/multiverse/grape-on-rails/lib/assets/.gitkeep +0 -0
- data/integration/multiverse/grape-on-rails/lib/tasks/.gitkeep +0 -0
- data/integration/multiverse/grape-on-rails/log/.gitkeep +0 -0
- data/integration/multiverse/grape-on-rails/public/404.html +0 -26
- data/integration/multiverse/grape-on-rails/public/422.html +0 -26
- data/integration/multiverse/grape-on-rails/public/500.html +0 -25
- data/integration/multiverse/grape-on-rails/public/favicon.ico +0 -0
- data/integration/multiverse/grape-on-rails/public/robots.txt +0 -5
- data/integration/multiverse/grape-on-rails/script/rails +0 -6
- data/integration/multiverse/grape-on-rails/spec/api/ping_spec.rb +0 -15
- data/integration/multiverse/grape-on-rails/spec/spec_helper.rb +0 -15
- data/integration/multiverse/rails42_app/.gitignore +0 -18
- data/integration/multiverse/rails42_app/Gemfile +0 -49
- data/integration/multiverse/rails42_app/Gemfile.lock +0 -167
- data/integration/multiverse/rails42_app/README.rdoc +0 -28
- data/integration/multiverse/rails42_app/Rakefile +0 -6
- data/integration/multiverse/rails42_app/app/assets/images/.keep +0 -0
- data/integration/multiverse/rails42_app/app/assets/javascripts/application.js +0 -16
- data/integration/multiverse/rails42_app/app/assets/javascripts/posts.coffee +0 -3
- data/integration/multiverse/rails42_app/app/assets/stylesheets/application.css +0 -15
- data/integration/multiverse/rails42_app/app/assets/stylesheets/posts.scss +0 -3
- data/integration/multiverse/rails42_app/app/assets/stylesheets/scaffolds.scss +0 -73
- data/integration/multiverse/rails42_app/app/controllers/application_controller.rb +0 -5
- data/integration/multiverse/rails42_app/app/controllers/concerns/.keep +0 -0
- data/integration/multiverse/rails42_app/app/controllers/posts_controller.rb +0 -75
- data/integration/multiverse/rails42_app/app/helpers/application_helper.rb +0 -2
- data/integration/multiverse/rails42_app/app/helpers/posts_helper.rb +0 -2
- data/integration/multiverse/rails42_app/app/jobs/foobar_cleanup_job.rb +0 -7
- data/integration/multiverse/rails42_app/app/mailers/.keep +0 -0
- data/integration/multiverse/rails42_app/app/models/.keep +0 -0
- data/integration/multiverse/rails42_app/app/models/concerns/.keep +0 -0
- data/integration/multiverse/rails42_app/app/models/post.rb +0 -2
- data/integration/multiverse/rails42_app/app/views/layouts/application.html.erb +0 -14
- data/integration/multiverse/rails42_app/app/views/posts/_form.html.erb +0 -21
- data/integration/multiverse/rails42_app/app/views/posts/edit.html.erb +0 -6
- data/integration/multiverse/rails42_app/app/views/posts/index.html.erb +0 -27
- data/integration/multiverse/rails42_app/app/views/posts/index.json.jbuilder +0 -4
- data/integration/multiverse/rails42_app/app/views/posts/new.html.erb +0 -5
- data/integration/multiverse/rails42_app/app/views/posts/show.html.erb +0 -9
- data/integration/multiverse/rails42_app/app/views/posts/show.json.jbuilder +0 -1
- data/integration/multiverse/rails42_app/bin/bundle +0 -3
- data/integration/multiverse/rails42_app/bin/rails +0 -9
- data/integration/multiverse/rails42_app/bin/rake +0 -9
- data/integration/multiverse/rails42_app/bin/setup +0 -29
- data/integration/multiverse/rails42_app/bin/spring +0 -15
- data/integration/multiverse/rails42_app/config/application.rb +0 -26
- data/integration/multiverse/rails42_app/config/boot.rb +0 -3
- data/integration/multiverse/rails42_app/config/database.yml +0 -25
- data/integration/multiverse/rails42_app/config/environment.rb +0 -5
- data/integration/multiverse/rails42_app/config/environments/development.rb +0 -41
- data/integration/multiverse/rails42_app/config/environments/production.rb +0 -79
- data/integration/multiverse/rails42_app/config/environments/test.rb +0 -42
- data/integration/multiverse/rails42_app/config/initializers/assets.rb +0 -11
- data/integration/multiverse/rails42_app/config/initializers/backtrace_silencers.rb +0 -7
- data/integration/multiverse/rails42_app/config/initializers/cookies_serializer.rb +0 -3
- data/integration/multiverse/rails42_app/config/initializers/filter_parameter_logging.rb +0 -4
- data/integration/multiverse/rails42_app/config/initializers/inflections.rb +0 -16
- data/integration/multiverse/rails42_app/config/initializers/mime_types.rb +0 -4
- data/integration/multiverse/rails42_app/config/initializers/session_store.rb +0 -3
- data/integration/multiverse/rails42_app/config/initializers/vitals.rb +0 -15
- data/integration/multiverse/rails42_app/config/initializers/wrap_parameters.rb +0 -14
- data/integration/multiverse/rails42_app/config/locales/en.yml +0 -23
- data/integration/multiverse/rails42_app/config/routes.rb +0 -57
- data/integration/multiverse/rails42_app/config/secrets.yml +0 -22
- data/integration/multiverse/rails42_app/config.ru +0 -4
- data/integration/multiverse/rails42_app/db/migrate/20160321140358_create_posts.rb +0 -9
- data/integration/multiverse/rails42_app/db/schema.rb +0 -22
- data/integration/multiverse/rails42_app/db/seeds.rb +0 -7
- data/integration/multiverse/rails42_app/lib/assets/.keep +0 -0
- data/integration/multiverse/rails42_app/lib/tasks/.keep +0 -0
- data/integration/multiverse/rails42_app/log/.keep +0 -0
- data/integration/multiverse/rails42_app/public/404.html +0 -67
- data/integration/multiverse/rails42_app/public/422.html +0 -67
- data/integration/multiverse/rails42_app/public/500.html +0 -66
- data/integration/multiverse/rails42_app/public/favicon.ico +0 -0
- data/integration/multiverse/rails42_app/public/robots.txt +0 -5
- data/integration/multiverse/rails42_app/test/controllers/.keep +0 -0
- data/integration/multiverse/rails42_app/test/controllers/posts_controller_test.rb +0 -49
- data/integration/multiverse/rails42_app/test/fixtures/.keep +0 -0
- data/integration/multiverse/rails42_app/test/fixtures/posts.yml +0 -7
- data/integration/multiverse/rails42_app/test/helpers/.keep +0 -0
- data/integration/multiverse/rails42_app/test/integration/.keep +0 -0
- data/integration/multiverse/rails42_app/test/integration/vitals_flow_test.rb +0 -96
- data/integration/multiverse/rails42_app/test/jobs/foobar_cleanup_job_test.rb +0 -7
- data/integration/multiverse/rails42_app/test/mailers/.keep +0 -0
- data/integration/multiverse/rails42_app/test/models/.keep +0 -0
- data/integration/multiverse/rails42_app/test/models/post_test.rb +0 -7
- data/integration/multiverse/rails42_app/test/test_helper.rb +0 -11
- data/integration/multiverse_helper.rb +0 -16
- data/integration/multiverse_spec.rb +0 -40
@@ -1,88 +0,0 @@
|
|
1
|
-
Grape API on Rack
|
2
|
-
=================
|
3
|
-
|
4
|
-
[![Build Status](https://travis-ci.org/ruby-grape/grape-on-rack.svg?branch=master)](https://travis-ci.org/ruby-grape/grape-on-rack)
|
5
|
-
[![Dependency Status](https://gemnasium.com/ruby-grape/grape-on-rack.svg)](https://gemnasium.com/ruby-grape/grape-on-rack)
|
6
|
-
[![Code Climate](https://codeclimate.com/github/ruby-grape/grape-on-rack.svg)](https://codeclimate.com/github/ruby-grape/grape-on-rack)
|
7
|
-
|
8
|
-
A [Grape](http://github.com/ruby-grape/grape) API mounted on Rack.
|
9
|
-
|
10
|
-
* [ping](api/ping.rb): a hello world example that returns a JSON document
|
11
|
-
* [post_put](api/post_put.rb): a simple `POST` and `PUT` example
|
12
|
-
* [post_json](api/post_json.rb): an example that shows a `POST` of JSON data
|
13
|
-
* [get_json](api/get_json.rb): an example that pre-processes params sent as JSON data
|
14
|
-
* [rescue_from](api/rescue_from.rb): an example of `rescue_from` that wraps all exceptions in an HTTP error code 500
|
15
|
-
* [path_versioning](api/path_versioning.rb): an example that uses path-based versioning
|
16
|
-
* [header_versioning](api/header_versioning.rb): an example that uses vendor header-based versioning
|
17
|
-
* [wrap_response](api/wrap_response.rb): a middleware that wraps all responses and always returns HTTP code 200
|
18
|
-
* [content_type](api/content_type.rb): an example that overrides the default `Content-Type` or returns data in both JSON and XML formats
|
19
|
-
* [upload_file](api/upload_file.rb): an example that demonstrates a file upload and download
|
20
|
-
* [entites](api/entities.rb): an example of using [grape-entity](https://github.com/ruby-grape/grape-entity)
|
21
|
-
|
22
|
-
See
|
23
|
-
---
|
24
|
-
|
25
|
-
There's a deployed [grape-on-rack on Heroku](http://grape-on-rack.herokuapp.com/).
|
26
|
-
|
27
|
-
Run
|
28
|
-
---
|
29
|
-
|
30
|
-
```
|
31
|
-
$ bundle install
|
32
|
-
$ rackup
|
33
|
-
|
34
|
-
Loading NewRelic in developer mode ...
|
35
|
-
[2013-06-20 08:57:58] INFO WEBrick 1.3.1
|
36
|
-
[2013-06-20 08:57:58] INFO ruby 1.9.3 (2013-02-06) [x86_64-darwin11.4.2]
|
37
|
-
[2013-06-20 08:57:58] INFO WEBrick::HTTPServer#start: pid=247 port=9292
|
38
|
-
```
|
39
|
-
|
40
|
-
### Hello World
|
41
|
-
|
42
|
-
Navigate to http://localhost:9292/api/ping with a browser or use `curl`.
|
43
|
-
|
44
|
-
```
|
45
|
-
$ curl http://localhost:9292/api/ping
|
46
|
-
|
47
|
-
{"ping":"pong"}
|
48
|
-
```
|
49
|
-
|
50
|
-
### Get Plain Text
|
51
|
-
|
52
|
-
```
|
53
|
-
$ curl http://localhost:9292/api/plain_text
|
54
|
-
|
55
|
-
A red brown fox jumped over the road.
|
56
|
-
```
|
57
|
-
|
58
|
-
### Upload a File
|
59
|
-
|
60
|
-
```
|
61
|
-
$ curl -X POST -i -F image_file=@spec/fixtures/grape_logo.png http://localhost:9292/api/avatar
|
62
|
-
|
63
|
-
{"filename":"grape_logo.png","size":4272}
|
64
|
-
```
|
65
|
-
|
66
|
-
### Upload and Download a File
|
67
|
-
|
68
|
-
```
|
69
|
-
$ curl -X POST -i -F file=@spec/fixtures/grape_logo.png http://localhost:9292/api/download.png
|
70
|
-
$ curl -X POST -i -F file=@api/ping.rb http://localhost:9292/api/download.rb
|
71
|
-
```
|
72
|
-
|
73
|
-
List Routes
|
74
|
-
-----------
|
75
|
-
|
76
|
-
```
|
77
|
-
rake routes
|
78
|
-
```
|
79
|
-
|
80
|
-
Explore the API
|
81
|
-
---------------
|
82
|
-
|
83
|
-
Explore the API using [Swagger UI](http://petstore.swagger.io). Run the application and point the explorer to `http://localhost:9292/api/swagger_doc` or `http://grape-on-rack.herokuapp.com/api/swagger_doc`.
|
84
|
-
|
85
|
-
New Relic
|
86
|
-
---------
|
87
|
-
|
88
|
-
The application is setup with NewRelic w/ Developer Mode. Navigate to http://localhost:9292/newrelic after making some API calls.
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler/setup'
|
3
|
-
|
4
|
-
require 'rake'
|
5
|
-
|
6
|
-
require 'rspec/core'
|
7
|
-
require 'rspec/core/rake_task'
|
8
|
-
|
9
|
-
RSpec::Core::RakeTask.new(:spec)
|
10
|
-
|
11
|
-
task :environment do
|
12
|
-
ENV['RACK_ENV'] ||= 'development'
|
13
|
-
require File.expand_path('../config/environment', __FILE__)
|
14
|
-
end
|
15
|
-
|
16
|
-
task routes: :environment do
|
17
|
-
Acme::API.routes.each do |route|
|
18
|
-
method = route.route_method.ljust(10)
|
19
|
-
path = route.route_path
|
20
|
-
puts " #{method} #{path}"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
require 'rubocop/rake_task'
|
25
|
-
RuboCop::RakeTask.new(:rubocop)
|
26
|
-
|
27
|
-
task default: [:rubocop, :spec]
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Acme
|
2
|
-
class ContentType < Grape::API
|
3
|
-
format :json
|
4
|
-
content_type :txt, 'text/plain'
|
5
|
-
content_type :xml, 'application/xml'
|
6
|
-
|
7
|
-
desc 'Returns a plain text file.'
|
8
|
-
get 'plain_text' do
|
9
|
-
content_type 'text/plain'
|
10
|
-
'A red brown fox jumped over the road.'
|
11
|
-
end
|
12
|
-
|
13
|
-
desc 'Returns a response in either XML or JSON format.'
|
14
|
-
get 'mixed' do
|
15
|
-
{ data: 'A red brown fox jumped over the road.' }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Acme
|
2
|
-
module Entities
|
3
|
-
class Tool < Grape::Entity
|
4
|
-
root 'tools', 'tool'
|
5
|
-
expose :id
|
6
|
-
expose :length, documentation: { type: :string, desc: 'length of the tool' }
|
7
|
-
expose :weight, documentation: { type: :string, desc: 'weight of the tool' }
|
8
|
-
expose :foo, documentation: { type: :string, desc: 'foo' }, if: ->(_tool, options) { options[:foo] } do |_tool, options|
|
9
|
-
options[:foo]
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class API < Grape::API
|
14
|
-
format :json
|
15
|
-
content_type :xml, 'application/xml'
|
16
|
-
formatter :xml, proc { |object|
|
17
|
-
object[object.keys.first].to_xml root: object.keys.first
|
18
|
-
}
|
19
|
-
desc 'Exposes an entity'
|
20
|
-
namespace :entities do
|
21
|
-
desc 'Expose a tool', params: Acme::Entities::Tool.documentation
|
22
|
-
get ':id' do
|
23
|
-
present OpenStruct.new(id: params[:id], length: 10, weight: '20kg'), with: Acme::Entities::Tool, foo: params[:foo]
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Acme
|
2
|
-
class GetJson < Grape::API
|
3
|
-
format :json
|
4
|
-
desc 'Flips reticulated in a collection of splines passed as JSON in a query string.'
|
5
|
-
resource :reticulated_splines do
|
6
|
-
before do
|
7
|
-
params.each_pair do |k, v|
|
8
|
-
params[k] = JSON.parse(v) rescue v
|
9
|
-
end
|
10
|
-
end
|
11
|
-
params do
|
12
|
-
requires :splines, type: Array do
|
13
|
-
requires :id, type: Integer
|
14
|
-
requires :reticulated, type: Boolean
|
15
|
-
end
|
16
|
-
end
|
17
|
-
get do
|
18
|
-
params[:splines].map do |spline|
|
19
|
-
spline.merge(reticulated: !spline[:reticulated])
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Acme
|
2
|
-
class PostPut < Grape::API
|
3
|
-
cattr_accessor :rang
|
4
|
-
|
5
|
-
format :json
|
6
|
-
desc 'Returns pong.'
|
7
|
-
get :ring do
|
8
|
-
{ rang: PostPut.rang }
|
9
|
-
end
|
10
|
-
post :ring do
|
11
|
-
result = (PostPut.rang += 1)
|
12
|
-
{ rang: result }
|
13
|
-
end
|
14
|
-
params do
|
15
|
-
requires :count, type: Integer
|
16
|
-
end
|
17
|
-
put :ring do
|
18
|
-
result = (PostPut.rang += params[:count].to_i)
|
19
|
-
{ rang: result }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
Acme::PostPut.rang = 0
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Acme
|
2
|
-
class UploadFile < Grape::API
|
3
|
-
format :json
|
4
|
-
|
5
|
-
desc 'Upload an image.'
|
6
|
-
post 'avatar' do
|
7
|
-
{
|
8
|
-
filename: params[:image_file][:filename],
|
9
|
-
size: params[:image_file][:tempfile].size
|
10
|
-
}
|
11
|
-
end
|
12
|
-
|
13
|
-
desc 'Upload and download a file of any format.'
|
14
|
-
post 'download' do
|
15
|
-
filename = params[:file][:filename]
|
16
|
-
content_type MIME::Types.type_for(filename)[0].to_s
|
17
|
-
env['api.format'] = :binary
|
18
|
-
header 'Content-Disposition', "attachment; filename*=UTF-8''#{URI.escape(filename)}"
|
19
|
-
params[:file][:tempfile].read
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Acme
|
2
|
-
class WrapResponseDecorator
|
3
|
-
def initialize(app)
|
4
|
-
@app = app
|
5
|
-
end
|
6
|
-
|
7
|
-
def call(env)
|
8
|
-
status, headers, body_proxy = @app.call(env)
|
9
|
-
bodies = body_proxy.body.map do |body|
|
10
|
-
{ body: JSON.parse(body), status: status }.to_json
|
11
|
-
end
|
12
|
-
[200, headers, bodies]
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module Acme
|
2
|
-
class App
|
3
|
-
def initialize
|
4
|
-
@filenames = ['', '.html', 'index.html', '/index.html']
|
5
|
-
@rack_static = ::Rack::Static.new(
|
6
|
-
lambda { [404, {}, []] },
|
7
|
-
root: File.expand_path('../../public', __FILE__),
|
8
|
-
urls: ['/']
|
9
|
-
)
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.instance
|
13
|
-
@instance ||= Rack::Builder.new do
|
14
|
-
use Rack::Cors do
|
15
|
-
allow do
|
16
|
-
origins '*'
|
17
|
-
resource '*', headers: :any, methods: :get
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
run Acme::App.new
|
22
|
-
end.to_app
|
23
|
-
end
|
24
|
-
|
25
|
-
def call(env)
|
26
|
-
# api
|
27
|
-
response = Acme::API.call(env)
|
28
|
-
|
29
|
-
# Check if the App wants us to pass the response along to others
|
30
|
-
if response[1]['X-Cascade'] == 'pass'
|
31
|
-
# static files
|
32
|
-
request_path = env['PATH_INFO']
|
33
|
-
@filenames.each do |path|
|
34
|
-
response = @rack_static.call(env.merge('PATH_INFO' => request_path + path))
|
35
|
-
return response if response[0] != 404
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# Serve error pages or respond with API response
|
40
|
-
case response[0]
|
41
|
-
when 404, 500
|
42
|
-
content = @rack_static.call(env.merge('PATH_INFO' => "/errors/#{response[0]}.html"))
|
43
|
-
[response[0], content[1], content[2]]
|
44
|
-
else
|
45
|
-
response
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Acme
|
2
|
-
class API < Grape::API
|
3
|
-
prefix 'api'
|
4
|
-
format :json
|
5
|
-
mount ::Acme::Ping
|
6
|
-
mount ::Acme::RescueFrom
|
7
|
-
mount ::Acme::PathVersioning
|
8
|
-
mount ::Acme::HeaderVersioning
|
9
|
-
mount ::Acme::PostPut
|
10
|
-
mount ::Acme::WrapResponse
|
11
|
-
mount ::Acme::PostJson
|
12
|
-
mount ::Acme::GetJson
|
13
|
-
mount ::Acme::ContentType
|
14
|
-
mount ::Acme::UploadFile
|
15
|
-
mount ::Acme::Entities::API
|
16
|
-
add_swagger_documentation api_version: 'v1'
|
17
|
-
end
|
18
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'api'))
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'app'))
|
3
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
|
-
|
5
|
-
require 'boot'
|
6
|
-
|
7
|
-
Bundler.require :default, ENV['RACK_ENV']
|
8
|
-
|
9
|
-
Dir[File.expand_path('../../api/*.rb', __FILE__)].each do |f|
|
10
|
-
require f
|
11
|
-
end
|
12
|
-
|
13
|
-
require 'api'
|
14
|
-
require 'acme_app'
|
15
|
-
|
16
|
-
require 'vitals'
|
17
|
-
Vitals.configure! do |c|
|
18
|
-
c.facility = 'grape_app'
|
19
|
-
end
|
20
|
-
|
21
|
-
require 'vitals/integrations/notifications/grape'
|
22
|
-
Vitals::Integrations::Notifications::Grape.subscribe!
|
23
|
-
|
@@ -1,255 +0,0 @@
|
|
1
|
-
# Here are the settings that are common to all environments
|
2
|
-
common: &default_settings
|
3
|
-
# ============================== LICENSE KEY ===============================
|
4
|
-
|
5
|
-
# You must specify the license key associated with your New Relic
|
6
|
-
# account. This key binds your Agent's data to your account in the
|
7
|
-
# New Relic service.
|
8
|
-
license_key: '<%= ENV["NEW_RELIC_LICENSE_KEY"] %>'
|
9
|
-
|
10
|
-
# Agent Enabled (Rails Only)
|
11
|
-
# Use this setting to force the agent to run or not run.
|
12
|
-
# Default is 'auto' which means the agent will install and run only
|
13
|
-
# if a valid dispatcher such as Mongrel is running. This prevents
|
14
|
-
# it from running with Rake or the console. Set to false to
|
15
|
-
# completely turn the agent off regardless of the other settings.
|
16
|
-
# Valid values are true, false and auto.
|
17
|
-
#
|
18
|
-
# agent_enabled: auto
|
19
|
-
|
20
|
-
# Application Name Set this to be the name of your application as
|
21
|
-
# you'd like it show up in New Relic. The service will then auto-map
|
22
|
-
# instances of your application into an "application" on your
|
23
|
-
# dashboard page. If you want to map this instance into multiple
|
24
|
-
# apps, like "AJAX Requests" and "All UI" then specify a semicolon
|
25
|
-
# separated list of up to three distinct names, or a yaml list.
|
26
|
-
# Defaults to the capitalized RAILS_ENV or RACK_ENV (i.e.,
|
27
|
-
# Production, Staging, etc)
|
28
|
-
#
|
29
|
-
# Example:
|
30
|
-
#
|
31
|
-
# app_name:
|
32
|
-
# - Ajax Service
|
33
|
-
# - All Services
|
34
|
-
#
|
35
|
-
app_name: <%= ENV["NEW_RELIC_APP_NAME"] || 'Demo' %>
|
36
|
-
|
37
|
-
# When "true", the agent collects performance data about your
|
38
|
-
# application and reports this data to the New Relic service at
|
39
|
-
# newrelic.com. This global switch is normally overridden for each
|
40
|
-
# environment below. (formerly called 'enabled')
|
41
|
-
monitor_mode: true
|
42
|
-
|
43
|
-
# Developer mode should be off in every environment but
|
44
|
-
# development as it has very high overhead in memory.
|
45
|
-
developer_mode: false
|
46
|
-
|
47
|
-
# The newrelic agent generates its own log file to keep its logging
|
48
|
-
# information separate from that of your application. Specify its
|
49
|
-
# log level here.
|
50
|
-
log_level: info
|
51
|
-
|
52
|
-
# Optionally set the path to the log file This is expanded from the
|
53
|
-
# root directory (may be relative or absolute, e.g. 'log/' or
|
54
|
-
# '/var/log/') The agent will attempt to create this directory if it
|
55
|
-
# does not exist.
|
56
|
-
# log_file_path: 'log'
|
57
|
-
|
58
|
-
# Optionally set the name of the log file, defaults to 'newrelic_agent.log'
|
59
|
-
# log_file_name: 'newrelic_agent.log'
|
60
|
-
|
61
|
-
# The newrelic agent communicates with the service via http by
|
62
|
-
# default. If you want to communicate via https to increase
|
63
|
-
# security, then turn on SSL by setting this value to true. Note,
|
64
|
-
# this will result in increased CPU overhead to perform the
|
65
|
-
# encryption involved in SSL communication, but this work is done
|
66
|
-
# asynchronously to the threads that process your application code,
|
67
|
-
# so it should not impact response times.
|
68
|
-
ssl: false
|
69
|
-
|
70
|
-
# EXPERIMENTAL: enable verification of the SSL certificate sent by
|
71
|
-
# the server. This setting has no effect unless SSL is enabled
|
72
|
-
# above. This may block your application. Only enable it if the data
|
73
|
-
# you send us needs end-to-end verified certificates.
|
74
|
-
#
|
75
|
-
# This means we cannot cache the DNS lookup, so each request to the
|
76
|
-
# service will perform a lookup. It also means that we cannot
|
77
|
-
# use a non-blocking lookup, so in a worst case, if you have DNS
|
78
|
-
# problems, your app may block indefinitely.
|
79
|
-
# verify_certificate: true
|
80
|
-
|
81
|
-
# Set your application's Apdex threshold value with the 'apdex_t'
|
82
|
-
# setting, in seconds. The apdex_t value determines the buckets used
|
83
|
-
# to compute your overall Apdex score.
|
84
|
-
# Requests that take less than apdex_t seconds to process will be
|
85
|
-
# classified as Satisfying transactions; more than apdex_t seconds
|
86
|
-
# as Tolerating transactions; and more than four times the apdex_t
|
87
|
-
# value as Frustrating transactions.
|
88
|
-
# For more about the Apdex standard, see
|
89
|
-
# http://newrelic.com/docs/general/apdex
|
90
|
-
|
91
|
-
apdex_t: 0.5
|
92
|
-
|
93
|
-
#============================== Browser Monitoring ===============================
|
94
|
-
# New Relic Real User Monitoring gives you insight into the performance real users are
|
95
|
-
# experiencing with your website. This is accomplished by measuring the time it takes for
|
96
|
-
# your users' browsers to download and render your web pages by injecting a small amount
|
97
|
-
# of JavaScript code into the header and footer of each page.
|
98
|
-
browser_monitoring:
|
99
|
-
# By default the agent automatically injects the monitoring JavaScript
|
100
|
-
# into web pages. Set this attribute to false to turn off this behavior.
|
101
|
-
auto_instrument: true
|
102
|
-
|
103
|
-
# Proxy settings for connecting to the service.
|
104
|
-
#
|
105
|
-
# If a proxy is used, the host setting is required. Other settings
|
106
|
-
# are optional. Default port is 8080.
|
107
|
-
#
|
108
|
-
# proxy_host: hostname
|
109
|
-
# proxy_port: 8080
|
110
|
-
# proxy_user:
|
111
|
-
# proxy_pass:
|
112
|
-
|
113
|
-
|
114
|
-
# Tells transaction tracer and error collector (when enabled)
|
115
|
-
# whether or not to capture HTTP params. When true, frameworks can
|
116
|
-
# exclude HTTP parameters from being captured.
|
117
|
-
# Rails: the RoR filter_parameter_logging excludes parameters
|
118
|
-
# Java: create a config setting called "ignored_params" and set it to
|
119
|
-
# a comma separated list of HTTP parameter names.
|
120
|
-
# ex: ignored_params: credit_card, ssn, password
|
121
|
-
capture_params: true
|
122
|
-
|
123
|
-
|
124
|
-
# Transaction tracer captures deep information about slow
|
125
|
-
# transactions and sends this to the service once a
|
126
|
-
# minute. Included in the transaction is the exact call sequence of
|
127
|
-
# the transactions including any SQL statements issued.
|
128
|
-
transaction_tracer:
|
129
|
-
|
130
|
-
# Transaction tracer is enabled by default. Set this to false to
|
131
|
-
# turn it off. This feature is only available at the Professional
|
132
|
-
# and above product levels.
|
133
|
-
enabled: true
|
134
|
-
|
135
|
-
# Threshold in seconds for when to collect a transaction
|
136
|
-
# trace. When the response time of a controller action exceeds
|
137
|
-
# this threshold, a transaction trace will be recorded and sent to
|
138
|
-
# the service. Valid values are any float value, or (default)
|
139
|
-
# "apdex_f", which will use the threshold for an dissatisfying
|
140
|
-
# Apdex controller action - four times the Apdex T value.
|
141
|
-
transaction_threshold: apdex_f
|
142
|
-
|
143
|
-
# When transaction tracer is on, SQL statements can optionally be
|
144
|
-
# recorded. The recorder has three modes, "off" which sends no
|
145
|
-
# SQL, "raw" which sends the SQL statement in its original form,
|
146
|
-
# and "obfuscated", which strips out numeric and string literals
|
147
|
-
record_sql: obfuscated
|
148
|
-
|
149
|
-
# Threshold in seconds for when to collect stack trace for a SQL
|
150
|
-
# call. In other words, when SQL statements exceed this threshold,
|
151
|
-
# then capture and send the current stack trace. This is
|
152
|
-
# helpful for pinpointing where long SQL calls originate from
|
153
|
-
stack_trace_threshold: 0.500
|
154
|
-
|
155
|
-
# Determines whether the agent will capture query plans for slow
|
156
|
-
# SQL queries. Only supported in mysql and postgres. Should be
|
157
|
-
# set to false when using other adapters.
|
158
|
-
# explain_enabled: true
|
159
|
-
|
160
|
-
# Threshold for query execution time below which query plans will not
|
161
|
-
# not be captured. Relevant only when `explain_enabled` is true.
|
162
|
-
# explain_threshold: 0.5
|
163
|
-
|
164
|
-
# Error collector captures information about uncaught exceptions and
|
165
|
-
# sends them to the service for viewing
|
166
|
-
error_collector:
|
167
|
-
|
168
|
-
# Error collector is enabled by default. Set this to false to turn
|
169
|
-
# it off. This feature is only available at the Professional and above
|
170
|
-
# product levels
|
171
|
-
enabled: true
|
172
|
-
|
173
|
-
# Rails Only - tells error collector whether or not to capture a
|
174
|
-
# source snippet around the place of the error when errors are View
|
175
|
-
# related.
|
176
|
-
capture_source: true
|
177
|
-
|
178
|
-
# To stop specific errors from reporting to New Relic, set this property
|
179
|
-
# to comma separated values. Default is to ignore routing errors
|
180
|
-
# which are how 404's get triggered.
|
181
|
-
#
|
182
|
-
ignore_errors: ActionController::RoutingError
|
183
|
-
|
184
|
-
# (Advanced) Uncomment this to ensure the cpu and memory samplers
|
185
|
-
# won't run. Useful when you are using the agent to monitor an
|
186
|
-
# external resource
|
187
|
-
# disable_samplers: true
|
188
|
-
|
189
|
-
# If you aren't interested in visibility in these areas, you can
|
190
|
-
# disable the instrumentation to reduce overhead.
|
191
|
-
#
|
192
|
-
# disable_view_instrumentation: true
|
193
|
-
# disable_activerecord_instrumentation: true
|
194
|
-
# disable_memcache_instrumentation: true
|
195
|
-
# disable_dj: true
|
196
|
-
|
197
|
-
# If you're interested in capturing memcache keys as though they
|
198
|
-
# were SQL uncomment this flag. Note that this does increase
|
199
|
-
# overhead slightly on every memcached call, and can have security
|
200
|
-
# implications if your memcached keys are sensitive
|
201
|
-
# capture_memcache_keys: true
|
202
|
-
|
203
|
-
# Certain types of instrumentation such as GC stats will not work if
|
204
|
-
# you are running multi-threaded. Please let us know.
|
205
|
-
# multi_threaded = false
|
206
|
-
|
207
|
-
# Application Environments
|
208
|
-
# ------------------------------------------
|
209
|
-
# Environment specific settings are in this section.
|
210
|
-
# For Rails applications, RAILS_ENV is used to determine the environment
|
211
|
-
# For Java applications, pass -Dnewrelic.environment <environment> to set
|
212
|
-
# the environment
|
213
|
-
|
214
|
-
# NOTE if your application has other named environments, you should
|
215
|
-
# provide newrelic configuration settings for these environments here.
|
216
|
-
|
217
|
-
development:
|
218
|
-
<<: *default_settings
|
219
|
-
# Turn off communication to New Relic service in development mode (also
|
220
|
-
# 'enabled').
|
221
|
-
# NOTE: for initial evaluation purposes, you may want to temporarily
|
222
|
-
# turn the agent on in development mode.
|
223
|
-
monitor_mode: false
|
224
|
-
|
225
|
-
# Rails Only - when running in Developer Mode, the New Relic Agent will
|
226
|
-
# present performance information on the last 100 transactions you have
|
227
|
-
# executed since starting the mongrel.
|
228
|
-
# NOTE: There is substantial overhead when running in developer mode.
|
229
|
-
# Do not use for production or load testing.
|
230
|
-
developer_mode: true
|
231
|
-
|
232
|
-
# Enable textmate links
|
233
|
-
# textmate: true
|
234
|
-
|
235
|
-
test:
|
236
|
-
<<: *default_settings
|
237
|
-
# It almost never makes sense to turn on the agent when running
|
238
|
-
# unit, functional or integration tests or the like.
|
239
|
-
monitor_mode: false
|
240
|
-
|
241
|
-
# Turn on the agent in production for 24x7 monitoring. NewRelic
|
242
|
-
# testing shows an average performance impact of < 5 ms per
|
243
|
-
# transaction, you you can leave this on all the time without
|
244
|
-
# incurring any user-visible performance degradation.
|
245
|
-
production:
|
246
|
-
<<: *default_settings
|
247
|
-
monitor_mode: true
|
248
|
-
|
249
|
-
# Many applications have a staging environment which behaves
|
250
|
-
# identically to production. Support for that environment is provided
|
251
|
-
# here. By default, the staging environment has the agent turned on.
|
252
|
-
staging:
|
253
|
-
<<: *default_settings
|
254
|
-
monitor_mode: true
|
255
|
-
app_name: <%= ENV["NEW_RELIC_APP_NAME"] || 'Demo' %> (Staging)
|