specwrk 0.4.2 → 0.4.3

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
  SHA256:
3
- metadata.gz: 9d76f2f9716e7c7e613bc0b341f89e42caf9375dfe0d48083afb908146d1374b
4
- data.tar.gz: 36136d67829a41b39f4e9de4fff45ea1a614111f9556a523eefde1b35cceba51
3
+ metadata.gz: 52798ca674b5b11b238ba315c34ada0357a0d4c52df995a04f3dbbdeaeb523eb
4
+ data.tar.gz: cf488e8d531ca483d3f8a7e6ce80600c55693028f05cba5321da190e3fdec114
5
5
  SHA512:
6
- metadata.gz: b7fd2a78d6019864949e6847f09474ad357b04614dd1a2cc3f563ec95f915e7958bfdf211c9d60213d61bea517e59e200ad3e7898963fe0cdd49df114941a786
7
- data.tar.gz: 6b1836bb1a50ba0d853689ec5b7f169c83883a39c134caf93b4a70637a81c3b4f6e4f8112285dca4b30065d0c6a816807e13e65ff748dc7b16d5c5d03064e52c
6
+ metadata.gz: 4d4fad41383ca3388bde45eebff774b9f052d2b830de7dca35774cc9f567236be56cdeb036207241617c8774684c07f9ec37d7e4d57eb75811117c29cbe78dae
7
+ data.tar.gz: 4f308d4b2c362981b2f88f4bdca0f6b271f96a354954dd911b3f1208fecd3c95f16e2fe84a44f0d2ba0e96dcfc38922228dd242f68ec7d49c0ea817d839fbf1c
data/lib/specwrk/cli.rb CHANGED
@@ -16,7 +16,7 @@ module Specwrk
16
16
  extend Hookable
17
17
 
18
18
  on_included do |base|
19
- base.unique_option :uri, type: :string, default: ENV.fetch("SPECWRK_SRV_URI", "http://localhost:#{ENV.fetch("SPECWRK_SRV_PORT", "5138")}"), desc: "HTTP URI of the server to pull jobs from. Overrides SPECWRK_SRV_PORT. Default 5138."
19
+ base.unique_option :uri, type: :string, default: ENV.fetch("SPECWRK_SRV_URI", "http://localhost:#{ENV.fetch("SPECWRK_SRV_PORT", "5138")}"), desc: "HTTP URI of the server to pull jobs from. Overrides SPECWRK_SRV_URI. Default http://localhost:5138."
20
20
  base.unique_option :key, type: :string, default: ENV.fetch("SPECWRK_SRV_KEY", ""), aliases: ["-k"], desc: "Authentication key clients must use for access. Overrides SPECWRK_SRV_KEY. Default ''."
21
21
  base.unique_option :run, type: :string, default: ENV.fetch("SPECWRK_RUN", "main"), aliases: ["-r"], desc: "The run identifier for this job execution. Overrides SPECWRK_RUN. Default main."
22
22
  base.unique_option :timeout, type: :integer, default: ENV.fetch("SPECWRK_TIMEOUT", "5"), aliases: ["-t"], desc: "The amount of time to wait for the server to respond. Overrides SPECWRK_TIMEOUT. Default 5."
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Specwrk
4
- VERSION = "0.4.2"
4
+ VERSION = "0.4.3"
5
5
  end
@@ -50,22 +50,24 @@ module Specwrk
50
50
  Rack::Builder.new do
51
51
  use Rack::Runtime
52
52
  use Specwrk::Web::Logger, $stdout
53
- use Specwrk::Web::Auth # global auth check
54
- run Specwrk::Web::App.new # your router
53
+ use Specwrk::Web::Auth, %w[/health] # global auth check
54
+ run Specwrk::Web::App.new # your router
55
55
  end
56
56
  end
57
57
  end
58
58
 
59
59
  def call(env)
60
- request = Rack::Request.new(env)
60
+ env[:request] ||= Rack::Request.new(env)
61
61
 
62
- route(method: request.request_method, path: request.path_info)
63
- .new(request)
62
+ route(method: env[:request].request_method, path: env[:request].path_info)
63
+ .new(env[:request])
64
64
  .response
65
65
  end
66
66
 
67
67
  def route(method:, path:)
68
68
  case [method, path]
69
+ when ["GET", "/health"]
70
+ Endpoints::Health
69
71
  when ["GET", "/heartbeat"]
70
72
  Endpoints::Heartbeat
71
73
  when ["POST", "/pop"]
@@ -5,12 +5,16 @@ require "rack/auth/abstract/request"
5
5
  module Specwrk
6
6
  class Web
7
7
  class Auth
8
- def initialize(app)
8
+ def initialize(app, excluded_paths = [])
9
9
  @app = app
10
+ @excluded_paths = excluded_paths
10
11
  end
11
12
 
12
13
  def call(env)
14
+ env[:request] ||= Rack::Request.new(env)
15
+
13
16
  return @app.call(env) if [nil, ""].include? ENV["SPECWRK_SRV_KEY"]
17
+ return @app.call(env) if @excluded_paths.include? env[:request].path_info
14
18
 
15
19
  auth = Rack::Auth::AbstractRequest.new(env)
16
20
 
@@ -50,6 +50,12 @@ module Specwrk
50
50
  # Base default response is 404
51
51
  NotFound = Class.new(Base)
52
52
 
53
+ class Health < Base
54
+ def response
55
+ ok
56
+ end
57
+ end
58
+
53
59
  class Heartbeat < Base
54
60
  def response
55
61
  ok
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specwrk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Westendorf