Commit c5d47bbe02a9dbba993e22c7affb0cc9e396b6e6

Authored by VoBa
Committed by GitHub
2 parents 48c5f080 b562e8ed

Merge pull request #303 from dmytro-landiak/master

rest api https support
... ... @@ -34,16 +34,23 @@ public class RestApiCallPlugin extends AbstractPlugin<RestApiCallPluginConfigura
34 34 private static final String AUTHORIZATION_HEADER_NAME = "Authorization";
35 35 private static final String AUTHORIZATION_HEADER_FORMAT = "Basic %s";
36 36 private static final String CREDENTIALS_TEMPLATE = "%s:%s";
37   - private static final String BASE_URL_TEMPLATE = "http://%s:%d%s";
  37 + private static final String BASE_URL_TEMPLATE = "%s%s:%d%s";
38 38 private RestApiCallMsgHandler handler;
39 39 private String baseUrl;
40 40 private HttpHeaders headers = new HttpHeaders();
41 41
42 42 @Override
43 43 public void init(RestApiCallPluginConfiguration configuration) {
  44 + String host = configuration.getHost();
  45 + host = host.trim();
  46 + if (host.contains("://")) {
  47 + host = host.substring(host.lastIndexOf('/') + 1, host.length());
  48 + }
  49 +
44 50 this.baseUrl = String.format(
45 51 BASE_URL_TEMPLATE,
46   - configuration.getHost(),
  52 + configuration.getProtocol(),
  53 + host,
47 54 configuration.getPort(),
48 55 configuration.getBasePath());
49 56
... ...
... ... @@ -22,6 +22,8 @@ import java.util.List;
22 22
23 23 @Data
24 24 public class RestApiCallPluginConfiguration {
  25 +
  26 + private String protocol;
25 27 private String host;
26 28 private int port;
27 29 private String basePath;
... ...
... ... @@ -3,6 +3,10 @@
3 3 "title": "REST API Call Plugin Configuration",
4 4 "type": "object",
5 5 "properties": {
  6 + "protocol": {
  7 + "title": "URI Scheme name",
  8 + "type": "string"
  9 + },
6 10 "host": {
7 11 "title": "Host",
8 12 "type": "string"
... ... @@ -51,6 +55,7 @@
51 55 }
52 56 },
53 57 "required": [
  58 + "protocol",
54 59 "host",
55 60 "port",
56 61 "basePath",
... ... @@ -58,6 +63,21 @@
58 63 ]
59 64 },
60 65 "form": [
  66 + {
  67 + "key": "protocol",
  68 + "type": "rc-select",
  69 + "multiple": false,
  70 + "items": [
  71 + {
  72 + "value": "http://",
  73 + "label": "HTTP"
  74 + },
  75 + {
  76 + "value": "https://",
  77 + "label": "HTTPS"
  78 + }
  79 + ]
  80 + },
61 81 "host",
62 82 "port",
63 83 "basePath",
... ...