rack-webfinger 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b9a43430d1f41be38e2b5e38fdcba83610562bd44e7f2a456a02be9e3a85e18
4
- data.tar.gz: 7f00c46856f655d5b89bad2e13c22761cc28dc22201b96ce88a15875f770690b
3
+ metadata.gz: 541982ded51019906d304bcf762e749171accfb90858067087ab8e69959c1838
4
+ data.tar.gz: 54dfc926cdfa893418db8ad0a6d129035821c818079f41ea8ddebdebf8320ecd
5
5
  SHA512:
6
- metadata.gz: 8c763cf4294ea00e20e6d4239474adb36f50ea8f94e4e431b83ea6bfd8b5b54df07335b7243f8a6ef9e3e78d95cb4c2da885b43e097f9851a0b9bd7eb70d47a2
7
- data.tar.gz: 35388dd7682829e76db423a71e3a8d3247ef6f3667f90aad2fec7ffe4aa0d5c3418e961654ff2ecdec9f104e986e7cf45b7521b39424dad8da70495f698809c1
6
+ metadata.gz: 6a2aff15955cbe4281f4dd40baecd5603506b0ce05922030d2498526fcee28badd31eed7e266e3a0f067eb9c3495fa0460933147f9a3fb2f1ac1a9cde1bd2fb6
7
+ data.tar.gz: c77db30be160f31f1264c17c3fccc9c6406d84006fa252bac472b71668200c400043ff72724efe20bffb1789b0123966ef36ffd75e30924f80ac5a67dad1b73d
data/README.md CHANGED
@@ -16,7 +16,33 @@ If bundler is not being used to manage dependencies, install the gem by executin
16
16
 
17
17
  ## Usage
18
18
 
19
- TODO: Write usage instructions here
19
+ In your `config.ru` add:
20
+
21
+ ```ruby
22
+ require 'rack/webfinger'
23
+
24
+ use Rack::Webfinger, provider
25
+ ```
26
+
27
+ `provider` must be a callable (lambda, proc, class responding to `#
28
+ call`) that takes a resource name and an array of rel filters in.
29
+ You can choose to ignore the rel filters - filtering will be done for
30
+ you.
31
+
32
+ You need to return a Hash of this format:
33
+
34
+ ```
35
+ {
36
+ aliases: ["list","of","aliases"],
37
+ links: [
38
+ { "rel": "rel url", "type": "text/html", "href": "link" }
39
+ ]
40
+ }
41
+ ```
42
+
43
+ This will be simplified, with constants for common rel values, and
44
+ defaults available.
45
+
20
46
 
21
47
  ## Development
22
48
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rack
4
4
  class Webfinger
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
@@ -6,21 +6,25 @@ require_relative "webfinger/version"
6
6
 
7
7
  module Rack
8
8
  class Webfinger
9
- def initialize(data_provider)
9
+ def initialize(app, data_provider)
10
+ @app = app
10
11
  @data_provider = data_provider
11
12
  end
12
13
 
13
- def not_found = [404, { 'Content-Type' => 'text/plain' }, ['Resource not found']]
14
+ def not_found = [404, { 'content-type' => 'text/plain' }, ['Resource not found']]
14
15
 
15
16
  def call(env)
16
17
  request = Rack::Request.new(env)
17
18
 
18
- return not_found if request.path != '/.well-known/webfinger'
19
+ if request.path != '/.well-known/webfinger'
20
+ return @app.call(env) if @app
21
+ return not_found
22
+ end
19
23
 
20
24
  resource = request.params['resource']
21
25
 
22
26
  if !resource
23
- return [400, { 'Content-Type' => 'text/plain' }, ['Missing resource parameter']]
27
+ return [400, { 'content-type' => 'text/plain' }, ['Missing resource parameter']]
24
28
  end
25
29
 
26
30
  # We need this because Rack's handling of the query string by default overwrites
@@ -41,7 +45,7 @@ module Rack
41
45
  filtered_data = filter_by_rel(response_data, rel_params)
42
46
 
43
47
  [200,
44
- { 'Content-Type' => 'application/jrd+json' },
48
+ { 'content-type' => 'application/jrd+json' },
45
49
  [JSON.generate(filtered_data)]
46
50
  ]
47
51
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-webfinger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vidar Hokstad
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-27 00:00:00.000000000 Z
11
+ date: 2024-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack-test