Commit 0f34ff518801c5f20c1ffb84b3dd320d74a05388
1 parent
611c970f
TB-57: Added support for custom header of REST API Call Plugin
Showing
3 changed files
with
32 additions
and
1 deletions
... | ... | @@ -55,6 +55,13 @@ public class RestApiCallPlugin extends AbstractPlugin<RestApiCallPluginConfigura |
55 | 55 | this.headers.add(AUTHORIZATION_HEADER_NAME, String.format(AUTHORIZATION_HEADER_FORMAT, new String(token))); |
56 | 56 | } |
57 | 57 | |
58 | + if (configuration.getHeaders() != null) { | |
59 | + configuration.getHeaders().forEach(h -> { | |
60 | + log.debug("Adding header to request object. Key = {}, Value = {}", h.getKey(), h.getValue()); | |
61 | + this.headers.add(h.getKey(), h.getValue()); | |
62 | + }); | |
63 | + } | |
64 | + | |
58 | 65 | init(); |
59 | 66 | } |
60 | 67 | ... | ... |
... | ... | @@ -16,6 +16,9 @@ |
16 | 16 | package org.thingsboard.server.extensions.rest.plugin; |
17 | 17 | |
18 | 18 | import lombok.Data; |
19 | +import org.thingsboard.server.extensions.core.plugin.KeyValuePluginProperties; | |
20 | + | |
21 | +import java.util.List; | |
19 | 22 | |
20 | 23 | @Data |
21 | 24 | public class RestApiCallPluginConfiguration { |
... | ... | @@ -27,4 +30,6 @@ public class RestApiCallPluginConfiguration { |
27 | 30 | |
28 | 31 | private String userName; |
29 | 32 | private String password; |
33 | + | |
34 | + private List<KeyValuePluginProperties> headers; | |
30 | 35 | } | ... | ... |
... | ... | @@ -30,6 +30,24 @@ |
30 | 30 | "password": { |
31 | 31 | "title": "Password", |
32 | 32 | "type": "string" |
33 | + }, | |
34 | + "headers": { | |
35 | + "title": "Request Headers", | |
36 | + "type": "array", | |
37 | + "items": { | |
38 | + "title": "Request Header", | |
39 | + "type": "object", | |
40 | + "properties": { | |
41 | + "key": { | |
42 | + "title": "Key", | |
43 | + "type": "string" | |
44 | + }, | |
45 | + "value": { | |
46 | + "title": "Value", | |
47 | + "type": "string" | |
48 | + } | |
49 | + } | |
50 | + } | |
33 | 51 | } |
34 | 52 | }, |
35 | 53 | "required": [ |
... | ... | @@ -62,6 +80,7 @@ |
62 | 80 | { |
63 | 81 | "key": "password", |
64 | 82 | "type": "password" |
65 | - } | |
83 | + }, | |
84 | + "headers" | |
66 | 85 | ] |
67 | 86 | } |
\ No newline at end of file | ... | ... |