web_pipe 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/web_pipe/conn_support/builder.rb +2 -2
- data/lib/web_pipe/conn_support/types.rb +2 -2
- data/lib/web_pipe/dsl/dsl_context.rb +8 -8
- data/lib/web_pipe/dsl/instance_methods.rb +8 -8
- data/lib/web_pipe/extensions/cookies/cookies.rb +3 -3
- data/lib/web_pipe/extensions/session/session.rb +2 -2
- data/lib/web_pipe/{rack → rack_support}/app_with_middlewares.rb +4 -4
- data/lib/web_pipe/{rack → rack_support}/middleware.rb +2 -2
- data/lib/web_pipe/{rack → rack_support}/middleware_specification.rb +8 -8
- data/lib/web_pipe/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09151400e351c909383b2cc9308910d209c6207fc978a55c59eb02997d29b3c7'
|
4
|
+
data.tar.gz: c2fff9105cc8cecc5aad8e2a7232f1a902bb3ec5d30e3a6b4e130db6128ba57b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da96a1e7cdd4278db92e14692248046dbcbeb04c1592ae01dd326b3958f42873f0564080ba70379690ec390bf37160885bbe20e591b6281b97617bac0cc402e5
|
7
|
+
data.tar.gz: e429d891a90cd7c90d9ccf11baca675c508906891c07f833a937c90d3ba751a7f85d73b03823be037e80a77cc20ba729c75115e61f6891829774614813045804
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
6
|
|
7
|
+
## [0.8.0] - 2019-08-30
|
8
|
+
### Added
|
9
|
+
- **BREAKING**. Rename `Rack` module to `RackSupport`.
|
10
|
+
[[#34]](https://github.com/waiting-for-dev/web_pipe/pull/34)
|
11
|
+
|
7
12
|
## [0.7.0] - 2019-08-27
|
8
13
|
### Added
|
9
14
|
- **BREAKING**. `Conn#config` instead of `Conn#bag` for extension configuration.
|
@@ -14,7 +14,7 @@ module WebPipe
|
|
14
14
|
#
|
15
15
|
# @return [Conn::Ongoing]
|
16
16
|
def self.call(env)
|
17
|
-
rr =
|
17
|
+
rr = Rack::Request.new(env)
|
18
18
|
Conn::Ongoing.new(
|
19
19
|
request: rr,
|
20
20
|
env: env,
|
@@ -33,4 +33,4 @@ module WebPipe
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
36
|
-
end
|
36
|
+
end
|
@@ -11,7 +11,7 @@ module WebPipe
|
|
11
11
|
include Dry.Types()
|
12
12
|
|
13
13
|
Env = Strict::Hash
|
14
|
-
Request = Instance(
|
14
|
+
Request = Instance(Rack::Request)
|
15
15
|
|
16
16
|
Scheme = Strict::Symbol.enum(:http, :https)
|
17
17
|
Method = Strict::Symbol.enum(
|
@@ -39,4 +39,4 @@ module WebPipe
|
|
39
39
|
default { {} }
|
40
40
|
end
|
41
41
|
end
|
42
|
-
end
|
42
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'web_pipe'
|
2
2
|
require 'web_pipe/types'
|
3
3
|
require 'web_pipe/plug'
|
4
|
-
require 'web_pipe/
|
4
|
+
require 'web_pipe/rack_support/middleware_specification'
|
5
5
|
|
6
6
|
module WebPipe
|
7
7
|
module DSL
|
@@ -13,7 +13,7 @@ module WebPipe
|
|
13
13
|
# @api private
|
14
14
|
class DSLContext
|
15
15
|
# @!attribute middleware_specifications
|
16
|
-
# @return [Array<
|
16
|
+
# @return [Array<RackSupport::MiddlewareSpecifications>]
|
17
17
|
attr_reader :middleware_specifications
|
18
18
|
|
19
19
|
# @!attribute plugs
|
@@ -22,7 +22,7 @@ module WebPipe
|
|
22
22
|
|
23
23
|
def initialize(middleware_specifications, plugs)
|
24
24
|
@middleware_specifications = Types.Array(
|
25
|
-
|
25
|
+
RackSupport::MiddlewareSpecification
|
26
26
|
)[middleware_specifications]
|
27
27
|
@plugs = Types.Array(Plug::Instance)[plugs]
|
28
28
|
end
|
@@ -37,12 +37,12 @@ module WebPipe
|
|
37
37
|
# - As a {WebPipe} class instance, in which case all its rack
|
38
38
|
# middlewares will be considered.
|
39
39
|
#
|
40
|
-
# @param name [
|
41
|
-
# @param spec [
|
40
|
+
# @param name [RackSupport::MiddlewareSpecification::Name[]]
|
41
|
+
# @param spec [RackSupport::MiddlewareSpecification::Spec[]]
|
42
42
|
#
|
43
|
-
# @return [Array<
|
43
|
+
# @return [Array<RackSupport::Middleware>]
|
44
44
|
def use(name, *spec)
|
45
|
-
middleware_specifications <<
|
45
|
+
middleware_specifications << RackSupport::MiddlewareSpecification.new(name: name, spec: spec)
|
46
46
|
end
|
47
47
|
|
48
48
|
# Creates and adds a plug to the stack.
|
@@ -80,4 +80,4 @@ module WebPipe
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
83
|
-
end
|
83
|
+
end
|
@@ -2,8 +2,8 @@ require 'web_pipe/types'
|
|
2
2
|
require 'web_pipe/conn'
|
3
3
|
require 'web_pipe/app'
|
4
4
|
require 'web_pipe/plug'
|
5
|
-
require 'web_pipe/
|
6
|
-
require 'web_pipe/
|
5
|
+
require 'web_pipe/rack_support/app_with_middlewares'
|
6
|
+
require 'web_pipe/rack_support/middleware_specification'
|
7
7
|
require 'web_pipe/conn_support/composition'
|
8
8
|
|
9
9
|
module WebPipe
|
@@ -29,7 +29,7 @@ module WebPipe
|
|
29
29
|
# Type for how plugs and middlewares should be injected.
|
30
30
|
Injections = Types::Strict::Hash.schema(
|
31
31
|
plugs: Plug::Injections,
|
32
|
-
middlewares:
|
32
|
+
middlewares: RackSupport::MiddlewareSpecification::Injections
|
33
33
|
)
|
34
34
|
|
35
35
|
# @!attribute [r] injections [Injections[]]
|
@@ -37,26 +37,26 @@ module WebPipe
|
|
37
37
|
# has been configured.
|
38
38
|
attr_reader :injections
|
39
39
|
|
40
|
-
# @return [
|
40
|
+
# @return [RackSupport::AppWithMiddlewares[]]
|
41
41
|
attr_reader :rack_app
|
42
42
|
|
43
43
|
# @return [ConnSupport::Composition::Operation[]]
|
44
44
|
attr_reader :operations
|
45
45
|
|
46
|
-
# @return [Array<
|
46
|
+
# @return [Array<RackSupport::Middlewares>]
|
47
47
|
attr_reader :middlewares
|
48
48
|
|
49
49
|
def initialize(injects = EMPTY_INJECTIONS)
|
50
50
|
@injections = Injections[injects]
|
51
51
|
container = self.class.container
|
52
|
-
@middlewares =
|
52
|
+
@middlewares = RackSupport::MiddlewareSpecification.inject_and_resolve(
|
53
53
|
self.class.middleware_specifications, injections[:middlewares]
|
54
54
|
)
|
55
55
|
@operations = Plug.inject_and_resolve(
|
56
56
|
self.class.plugs, injections[:plugs], container, self
|
57
57
|
)
|
58
58
|
app = App.new(operations)
|
59
|
-
@rack_app =
|
59
|
+
@rack_app = RackSupport::AppWithMiddlewares.new(middlewares, app)
|
60
60
|
end
|
61
61
|
|
62
62
|
# Expected interface for rack.
|
@@ -107,4 +107,4 @@ module WebPipe
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
110
|
-
end
|
110
|
+
end
|
@@ -60,7 +60,7 @@ module WebPipe
|
|
60
60
|
# @param value [String]
|
61
61
|
# @param opts [SET_COOKIE_OPTIONS[]]
|
62
62
|
def set_cookie(key, value, opts = Types::EMPTY_HASH)
|
63
|
-
|
63
|
+
Rack::Utils.set_cookie_header!(
|
64
64
|
response_headers,
|
65
65
|
key,
|
66
66
|
{ value: value }.merge(SET_COOKIE_OPTIONS[opts])
|
@@ -71,7 +71,7 @@ module WebPipe
|
|
71
71
|
# @param key [String]
|
72
72
|
# @param opts [DELETE_COOKIE_OPTIONS[]]
|
73
73
|
def delete_cookie(key, opts = Types::EMPTY_HASH)
|
74
|
-
|
74
|
+
Rack::Utils.delete_cookie_header!(
|
75
75
|
response_headers,
|
76
76
|
key,
|
77
77
|
DELETE_COOKIE_OPTIONS[opts]
|
@@ -81,4 +81,4 @@ module WebPipe
|
|
81
81
|
end
|
82
82
|
|
83
83
|
Conn.include(Cookies)
|
84
|
-
end
|
84
|
+
end
|
@@ -34,7 +34,7 @@ module WebPipe
|
|
34
34
|
#
|
35
35
|
# @return [Rack::Session::Abstract::SessionHash]
|
36
36
|
def session
|
37
|
-
env.fetch(
|
37
|
+
env.fetch(Rack::RACK_SESSION) do
|
38
38
|
raise ConnSupport::MissingMiddlewareError.new(
|
39
39
|
'session', 'Rack::Session', 'https://www.rubydoc.info/github/rack/rack/Rack/Session'
|
40
40
|
)
|
@@ -83,4 +83,4 @@ module WebPipe
|
|
83
83
|
end
|
84
84
|
|
85
85
|
Conn.include(Session)
|
86
|
-
end
|
86
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'web_pipe/types'
|
2
|
-
require 'web_pipe/
|
2
|
+
require 'web_pipe/rack_support/middleware'
|
3
3
|
require 'rack'
|
4
4
|
|
5
5
|
module WebPipe
|
6
|
-
module
|
6
|
+
module RackSupport
|
7
7
|
# Helper to build and call a rack application with middlewares.
|
8
8
|
#
|
9
9
|
# @api private
|
@@ -43,7 +43,7 @@ module WebPipe
|
|
43
43
|
private
|
44
44
|
|
45
45
|
def build_rack_app(rack_middlewares, app)
|
46
|
-
|
46
|
+
Rack::Builder.new.tap do |b|
|
47
47
|
rack_middlewares.each do |middleware|
|
48
48
|
b.use(middleware.middleware, *middleware.options)
|
49
49
|
end
|
@@ -52,4 +52,4 @@ module WebPipe
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
55
|
-
end
|
55
|
+
end
|
@@ -2,7 +2,7 @@ require 'web_pipe/types'
|
|
2
2
|
require 'dry/struct'
|
3
3
|
|
4
4
|
module WebPipe
|
5
|
-
module
|
5
|
+
module RackSupport
|
6
6
|
# Simple data structure to represent a rack middleware class with
|
7
7
|
# its initialization options.
|
8
8
|
#
|
@@ -23,4 +23,4 @@ module WebPipe
|
|
23
23
|
attribute :options, Options
|
24
24
|
end
|
25
25
|
end
|
26
|
-
end
|
26
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'dry/struct'
|
2
|
-
require 'web_pipe/
|
2
|
+
require 'web_pipe/rack_support/middleware'
|
3
3
|
require 'web_pipe/types'
|
4
4
|
|
5
5
|
module WebPipe
|
6
|
-
module
|
6
|
+
module RackSupport
|
7
7
|
# Specification on how to resolve {Rack::Middleware}'s.
|
8
8
|
#
|
9
9
|
# Rack middlewares can be specified in two ways:
|
@@ -11,8 +11,8 @@ module WebPipe
|
|
11
11
|
# - As an array where fist element is a rack middleware class
|
12
12
|
# while the rest of elements are its initialization options.
|
13
13
|
# - A single element array where it is an instance of a class
|
14
|
-
# including {WebPipe}. This specifies all {
|
15
|
-
#
|
14
|
+
# including {WebPipe}. This specifies all {RackSupport::Middlewares} for
|
15
|
+
# that {WebPipe}.
|
16
16
|
#
|
17
17
|
# @api private
|
18
18
|
class MiddlewareSpecification < Dry::Struct
|
@@ -26,7 +26,7 @@ module WebPipe
|
|
26
26
|
#
|
27
27
|
# @see #inject_and_resolve
|
28
28
|
Injections = Types::Strict::Hash.map(
|
29
|
-
|
29
|
+
RackSupport::MiddlewareSpecification::Name, RackSupport::MiddlewareSpecification::Spec
|
30
30
|
).default(Types::EMPTY_HASH)
|
31
31
|
|
32
32
|
# @!attribute [r] name
|
@@ -42,7 +42,7 @@ module WebPipe
|
|
42
42
|
# @param middleware_specifications [Array<MiddlewareSpecification>]
|
43
43
|
# @param injections [Injections[]]
|
44
44
|
#
|
45
|
-
# @return [Array<
|
45
|
+
# @return [Array<RackSupport::Middleware>]
|
46
46
|
def self.inject_and_resolve(middleware_specifications, injections)
|
47
47
|
middleware_specifications.map do |spec|
|
48
48
|
if injections.has_key?(spec.name)
|
@@ -53,9 +53,9 @@ module WebPipe
|
|
53
53
|
end.flatten
|
54
54
|
end
|
55
55
|
|
56
|
-
# Resolves {
|
56
|
+
# Resolves {RackSupport::Middlewares} from given specification.
|
57
57
|
#
|
58
|
-
# @return [Array<
|
58
|
+
# @return [Array<RackSupport::Middleware>]
|
59
59
|
def call
|
60
60
|
klass = spec[0]
|
61
61
|
options = spec[1..-1] || Types::EMPTY_ARRAY
|
data/lib/web_pipe/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web_pipe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc Busqué
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -272,9 +272,9 @@ files:
|
|
272
272
|
- lib/web_pipe/plugs.rb
|
273
273
|
- lib/web_pipe/plugs/config.rb
|
274
274
|
- lib/web_pipe/plugs/content_type.rb
|
275
|
-
- lib/web_pipe/
|
276
|
-
- lib/web_pipe/
|
277
|
-
- lib/web_pipe/
|
275
|
+
- lib/web_pipe/rack_support/app_with_middlewares.rb
|
276
|
+
- lib/web_pipe/rack_support/middleware.rb
|
277
|
+
- lib/web_pipe/rack_support/middleware_specification.rb
|
278
278
|
- lib/web_pipe/types.rb
|
279
279
|
- lib/web_pipe/version.rb
|
280
280
|
- web_pipe.gemspec
|