@toa.io/extensions.exposition 1.0.0-alpha.46 → 1.0.0-alpha.47

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.
@@ -136,8 +136,11 @@ The value of the directive is an object with the following properties:
136
136
  Defaults to `true`.
137
137
  - `redirect`: `string` specifying endpoint to be called for the redirection url.
138
138
 
139
- Redirection endpoint must return a `string` or an `Error`.
140
- Request `authority`, `path` and `parameters` are passed as input.
139
+ Request `authority`, `path` and `parameters` are passed as input to redirection endpoint,
140
+ and it must return a `string` or an `Error`.
141
+ If it returns a `string` then the response of the `GET` request to this URL is returned as the
142
+ response of the original request,
143
+ among with the `content-type`, `content-length`, and `etag` headers.
141
144
 
142
145
  ```yaml
143
146
  /images:
@@ -6,7 +6,7 @@ Feature: Octets redirection
6
6
  """yaml
7
7
  /:
8
8
  octets:context: octets
9
- /:foo/*:
9
+ /:type:
10
10
  GET:
11
11
  anonymous: true
12
12
  io:output: true
@@ -15,7 +15,7 @@ Feature: Octets redirection
15
15
  """
16
16
  When the following request is received:
17
17
  """
18
- GET /bar/direct HTTP/1.1
18
+ GET /rfc HTTP/1.1
19
19
  host: nex.toa.io
20
20
  """
21
21
  Then the following reply is sent:
@@ -25,3 +25,22 @@ Feature: Octets redirection
25
25
 
26
26
  Faster Than Light Speed Protocol (FLIP)
27
27
  """
28
+ When the following request is received:
29
+ """
30
+ GET /img HTTP/1.1
31
+ host: nex.toa.io
32
+ """
33
+ Then the following reply is sent:
34
+ """
35
+ 200 OK
36
+ content-type: image/svg+xml
37
+ """
38
+ When the following request is received:
39
+ """
40
+ GET /err HTTP/1.1
41
+ host: nex.toa.io
42
+ """
43
+ Then the following reply is sent:
44
+ """
45
+ 404 Not Found
46
+ """
@@ -1,7 +1,12 @@
1
1
  'use strict'
2
2
 
3
3
  async function redirect (input) {
4
- return 'https://www.rfc-editor.org/rfc/rfc9564.txt'
4
+ return urls[input.parameters.type] ?? new Error()
5
+ }
6
+
7
+ const urls = {
8
+ 'rfc': 'https://www.rfc-editor.org/rfc/rfc9564.txt',
9
+ 'img': 'https://www.w3.org/assets/logos/w3c/w3c-no-bars.svg'
5
10
  }
6
11
 
7
12
  exports.computation = redirect
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/extensions.exposition",
3
- "version": "1.0.0-alpha.46",
3
+ "version": "1.0.0-alpha.47",
4
4
  "description": "Toa Exposition",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -17,9 +17,9 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@toa.io/core": "1.0.0-alpha.46",
21
- "@toa.io/generic": "1.0.0-alpha.46",
22
- "@toa.io/schemas": "1.0.0-alpha.46",
20
+ "@toa.io/core": "1.0.0-alpha.47",
21
+ "@toa.io/generic": "1.0.0-alpha.47",
22
+ "@toa.io/schemas": "1.0.0-alpha.47",
23
23
  "bcryptjs": "2.4.3",
24
24
  "error-value": "0.3.0",
25
25
  "js-yaml": "4.1.0",
@@ -44,11 +44,11 @@
44
44
  "features:security": "cucumber-js --tags @security"
45
45
  },
46
46
  "devDependencies": {
47
- "@toa.io/agent": "1.0.0-alpha.46",
48
- "@toa.io/extensions.storages": "1.0.0-alpha.46",
47
+ "@toa.io/agent": "1.0.0-alpha.47",
48
+ "@toa.io/extensions.storages": "1.0.0-alpha.47",
49
49
  "@types/bcryptjs": "2.4.3",
50
50
  "@types/cors": "2.8.13",
51
51
  "@types/negotiator": "0.6.1"
52
52
  },
53
- "gitHead": "60d2cc702afd217de1760d2df2e6ad76893ac18c"
53
+ "gitHead": "9e3d26277392e1500d500664559ae9332f60d436"
54
54
  }