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 +4 -4
- data/lib/specwrk/cli.rb +1 -1
- data/lib/specwrk/version.rb +1 -1
- data/lib/specwrk/web/app.rb +7 -5
- data/lib/specwrk/web/auth.rb +5 -1
- data/lib/specwrk/web/endpoints.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52798ca674b5b11b238ba315c34ada0357a0d4c52df995a04f3dbbdeaeb523eb
|
4
|
+
data.tar.gz: cf488e8d531ca483d3f8a7e6ce80600c55693028f05cba5321da190e3fdec114
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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."
|
data/lib/specwrk/version.rb
CHANGED
data/lib/specwrk/web/app.rb
CHANGED
@@ -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
|
54
|
-
run Specwrk::Web::App.new
|
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
|
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"]
|
data/lib/specwrk/web/auth.rb
CHANGED
@@ -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
|
|