rutter 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bench/config.ru +1 -1
- data/lib/rutter.rb +8 -3
- data/lib/rutter/builder.rb +1 -2
- data/lib/rutter/route.rb +2 -2
- data/lib/rutter/version.rb +1 -1
- data/spec/integration/rack_spec.rb +1 -1
- metadata +2 -3
- data/lib/rutter/verbs.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4df69773cb0979c061fae5c421243b6d0b9892e244a0eb14442b894c8657e094
|
4
|
+
data.tar.gz: 0dc82eefc22f4f82c79b6e85dab56605ee9eab02c99ccea063c51d9734eb66d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29296019b52750432a1386e465ec29611d3bd47261b80e7a50992ecb973ccd787775e4eec42fbe98a9bf0efd8b75e25644f3a750f315f6c5694106972b79cfdc
|
7
|
+
data.tar.gz: 0f808af9d007dfd92be6eac06cb9be4a794efbf5c9b9b9e4a18f69c9fee7705bd4864cdaba5f55933011d2118886ea2cfdafb4237a8f51f96d75d44c95d9a1c7
|
data/bench/config.ru
CHANGED
@@ -10,7 +10,7 @@ router = Rutter.new do
|
|
10
10
|
get "/", to: ->(_) { [200, {}, ["Hello World"]] }
|
11
11
|
|
12
12
|
# wrk -t 2 http://localhost:9292/ruby
|
13
|
-
get "/:lang", to: ->(env) { [200, {}, [env["
|
13
|
+
get "/:lang", to: ->(env) { [200, {}, [env["router.params"]["lang"]]] }
|
14
14
|
end.freeze
|
15
15
|
|
16
16
|
run router
|
data/lib/rutter.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "rutter/version"
|
4
|
-
require_relative "rutter/builder"
|
5
|
-
|
6
3
|
# HTTP router for Rack.
|
7
4
|
module Rutter
|
5
|
+
# Supported request verbs.
|
6
|
+
#
|
7
|
+
# @return [Array]
|
8
|
+
VERBS = %w[GET POST PUT PATCH DELETE OPTIONS].freeze
|
9
|
+
|
10
|
+
require_relative "rutter/version"
|
11
|
+
require_relative "rutter/builder"
|
12
|
+
|
8
13
|
# Factory method for creating a new builder object.
|
9
14
|
#
|
10
15
|
# @param base [String]
|
data/lib/rutter/builder.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require "uri"
|
4
4
|
|
5
5
|
require_relative "naming"
|
6
|
-
require_relative "verbs"
|
7
6
|
require_relative "route"
|
8
7
|
require_relative "mount"
|
9
8
|
require_relative "scope"
|
@@ -40,7 +39,7 @@ module Rutter
|
|
40
39
|
def initialize(base: "http://localhost:9292", &block)
|
41
40
|
@uri = URI(base).freeze
|
42
41
|
@flat_map = []
|
43
|
-
@verb_map =
|
42
|
+
@verb_map = VERBS.map { |v| [v, []] }.to_h
|
44
43
|
@named_map = {}
|
45
44
|
|
46
45
|
instance_eval(&block) if block_given?
|
data/lib/rutter/route.rb
CHANGED
@@ -84,8 +84,8 @@ module Rutter
|
|
84
84
|
#
|
85
85
|
# @private
|
86
86
|
def call(env)
|
87
|
-
env["
|
88
|
-
env["
|
87
|
+
env["router.params"] ||= {}
|
88
|
+
env["router.params"].merge!(params(env["PATH_INFO"]))
|
89
89
|
env["rutter.action"] = @endpoint[:action]
|
90
90
|
|
91
91
|
ctrl = @endpoint[:controller]
|
data/lib/rutter/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rutter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Sandelius
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mustermann
|
@@ -117,7 +117,6 @@ files:
|
|
117
117
|
- lib/rutter/route.rb
|
118
118
|
- lib/rutter/routes.rb
|
119
119
|
- lib/rutter/scope.rb
|
120
|
-
- lib/rutter/verbs.rb
|
121
120
|
- lib/rutter/version.rb
|
122
121
|
- rutter.gemspec
|
123
122
|
- spec/integration/rack_spec.rb
|