Merge pull request #130 from volodymyr-babak/master

TB-57: Added support for custom header of REST API Call Plugin
This commit is contained in:
Andrew Shvayka 2017-05-07 14:10:57 +03:00 committed by GitHub
commit 7d09019fd2
3 changed files with 32 additions and 1 deletions

View File

@ -55,6 +55,13 @@ public class RestApiCallPlugin extends AbstractPlugin<RestApiCallPluginConfigura
this.headers.add(AUTHORIZATION_HEADER_NAME, String.format(AUTHORIZATION_HEADER_FORMAT, new String(token)));
}
if (configuration.getHeaders() != null) {
configuration.getHeaders().forEach(h -> {
log.debug("Adding header to request object. Key = {}, Value = {}", h.getKey(), h.getValue());
this.headers.add(h.getKey(), h.getValue());
});
}
init();
}

View File

@ -16,6 +16,9 @@
package org.thingsboard.server.extensions.rest.plugin;
import lombok.Data;
import org.thingsboard.server.extensions.core.plugin.KeyValuePluginProperties;
import java.util.List;
@Data
public class RestApiCallPluginConfiguration {
@ -27,4 +30,6 @@ public class RestApiCallPluginConfiguration {
private String userName;
private String password;
private List<KeyValuePluginProperties> headers;
}

View File

@ -30,6 +30,24 @@
"password": {
"title": "Password",
"type": "string"
},
"headers": {
"title": "Request Headers",
"type": "array",
"items": {
"title": "Request Header",
"type": "object",
"properties": {
"key": {
"title": "Key",
"type": "string"
},
"value": {
"title": "Value",
"type": "string"
}
}
}
}
},
"required": [
@ -62,6 +80,7 @@
{
"key": "password",
"type": "password"
}
},
"headers"
]
}