webrick-route_servlet 1.2.4 → 1.2.5

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: 0334e1ea8d016a6d57887661e08902cfa87946df
4
- data.tar.gz: cce1ddd704b5eac3153518b181f6e287abeeb653
3
+ metadata.gz: c41ace391d4524a5b3214938ca0c03f2b2d335a9
4
+ data.tar.gz: 8714cc1d1cd6a51d18fc6f7dd3ce4aa82bae86bc
5
5
  SHA512:
6
- metadata.gz: 182511c10133884117167979cd217f4ea8af43ff80ba1956a0ac390e306040c7ff69be432134a3fd5edfecc08085bd7575a12d53b09ffa69565f0cec8719ba96
7
- data.tar.gz: ea3825d8442f3a0ad972ebd2a8f2a1045ababda75bb11d5aaf70559d886c71ca919b8e439e0e93af46aa7331767b7ce0f8395b7cf0552bb53e12eb30ae26b9ab
6
+ metadata.gz: 7790eaccb7bac3d7e643fb87d7e807755fcbb6a7e7d25d95b1de5b84385ab0a1ef9312ea8b71a682b46d3710745cc1c5c54bd7c7ccfe2b89c6a4006e3dab8e9c
7
+ data.tar.gz: 04bc52e0687ec19021fdc3558ae3f59d6a0efd469465127604c5ea28c7d966746445e09060368a638fe52810eb2bc21dad4c51738e54526367f5fae9f1ade5a7
data/README.md CHANGED
@@ -75,6 +75,11 @@ only / except
75
75
  s.resources "/photo", PhotoServlet, :only => [:index]
76
76
  s.resources "/photo", PhotoServlet, :except => [:index, :show]
77
77
 
78
+ defaults
79
+
80
+ s.match "/photos/:id(.:format)", ActionServlet, :defaults => { :format => "json" }
81
+ s.match "/photos/:id(.:format)", ActionServlet, :format => "json"
82
+
78
83
  ## Contributing
79
84
 
80
85
  1. Fork it
@@ -45,8 +45,17 @@ module WEBrick
45
45
  if method==:* || method==req.request_method.to_sym
46
46
  md = re.match(req.path_info)
47
47
  if md
48
+ # path params
48
49
  params = Hash[md.names.map(&:to_sym).zip(md.captures)]
49
- params.delete_if{|k,v| v.nil?}
50
+
51
+ # default params
52
+ defaults = request_options[:defaults] || request_options
53
+ params.each do |k,v|
54
+ if v.nil?
55
+ params[k] = defaults[k]
56
+ end
57
+ end
58
+
50
59
  req.action = params[:action] || request_options[:action]
51
60
  req.params = params
52
61
  return [servlet, servlet_options]
@@ -1,5 +1,5 @@
1
1
  module WEBrick
2
2
  module RouteServlet
3
- VERSION = "1.2.4"
3
+ VERSION = "1.2.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webrick-route_servlet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshida Tetsuya