wet-health_endpoint 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52990292b1cb4a2eda36f202423ff983237a7b20
4
- data.tar.gz: f0f86b583dca1baeaee438ec5660878d231dd7e6
3
+ metadata.gz: 67ce805651db910c46de290c86cf856282983b0b
4
+ data.tar.gz: 9c3f6e397ff49531404b2ad67a7a2f01cb05ec85
5
5
  SHA512:
6
- metadata.gz: a3f6bfbebfe53755c205280af3c554110313fa43be14c5c3ba1464547193639cd61cc216b21fc3d01eb8feed110d7354b09790a5ba7795ec855e41be7ac8e47c
7
- data.tar.gz: 5920cfca186081fbce27b25756acb7795a8169d076e51e3ec2e874832cb3870607b839bda7b40221f3ae3f8853b55d7ab90a26a1a6e36929c3153807a9b803d5
6
+ metadata.gz: 3382e626db6e3ef620735a9a0b31012a9b1e44a80044d20727895a4ff1bfceded80eb7dae1ee6e9def4221b37a44d59b8c50e505f434184036b819a4a35e4c2f
7
+ data.tar.gz: 669611999303c3da4ee340d2b1b29c2fbb97cdf1b68d77b52686a868877d4439bca8611eadc4ebc8b6eeb0e99d838c62bc1302d997be6729b824729808ad3cc4
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Wet::HealthEndpoint
2
2
 
3
- Adds "/health" endpoint to Rails app so it can be monitored.
3
+ [![Build Status](https://travis-ci.org/wetrb/wet-health_endpoint.svg?branch=master)](https://travis-ci.org/wetrb/wet-health_endpoint)
4
+
5
+ Adds `/health` endpoint to Rails app so it can be monitored.
4
6
 
5
7
  ## Installation
6
8
 
@@ -0,0 +1,21 @@
1
+ module Wet
2
+ module HealthEndpoint
3
+ class Middleware
4
+ def initialize(app)
5
+ @app = app
6
+ end
7
+
8
+ def call(env)
9
+ dup._call(env)
10
+ end
11
+
12
+ def _call(env)
13
+ status, headers, body = @app.call(env)
14
+ return [204, {}, ['']] if status == 404 && env.fetch('PATH_INFO') == '/health'
15
+ [status, headers, body]
16
+ ensure
17
+ body.close if body && body.respond_to?(:close) && $!
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,10 +1,10 @@
1
+ require 'wet/health_endpoint/middleware'
2
+
1
3
  module Wet
2
4
  module HealthEndpoint
3
5
  class Railtie < Rails::Railtie
4
- initializer 'health_endpoint.routes', after: :after_initialize do |app|
5
- app.routes.draw do
6
- get '/health', to: proc { [204, {}, ['']] }
7
- end
6
+ initializer 'health_endpoint.routes' do |app|
7
+ app.middleware.use Middleware
8
8
  end
9
9
  end
10
10
  end
@@ -1,5 +1,5 @@
1
1
  module Wet
2
2
  module HealthEndpoint
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wet-health_endpoint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Szymon Fiedler
@@ -96,6 +96,7 @@ files:
96
96
  - bin/console
97
97
  - bin/setup
98
98
  - lib/wet/health_endpoint.rb
99
+ - lib/wet/health_endpoint/middleware.rb
99
100
  - lib/wet/health_endpoint/railtie.rb
100
101
  - lib/wet/health_endpoint/version.rb
101
102
  - wet-health_endpoint.gemspec