Skip to content

Commit

Permalink
Add http docs, support https (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnyz32 authored Oct 8, 2024
1 parent 70e508a commit a981da3
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ public synchronized Map<String, ManzanRoute> getRoutes(CamelContext context) {
getUriAndHeaderParameters(name, sectionObj, "sid", "token")));
break;
case "http":
case "https":
final String url = getRequiredString(name, "url");
ret.put(name, HttpDestination.get(name, url, format, getUriAndHeaderParameters(name, sectionObj, "url")));
ret.put(name, HttpDestination.get(name, type, url, format, getUriAndHeaderParameters(name, sectionObj, "url")));
break;
default:
throw new RuntimeException("Unknown destination type: " + type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

public class HttpDestination extends ManzanGenericCamelRoute {

public static HttpDestination get(final String _name, final String _url, final String _format, Map<String, String> _parameters) {
public static HttpDestination get(final String _name, String _type, final String _url, final String _format, Map<String, String> _parameters) {
Map<String, Object> headerParameters = new LinkedHashMap<String,Object>();
Map<String, String> uriParameters = new LinkedHashMap<String,String>();
String hostVal = _url.replaceFirst("^http://", "").replaceAll("\\/.*","");
String hostVal = _url.replaceFirst("^http(s)?://", "").replaceAll("\\/.*","");
headerParameters.put("Host", hostVal);
headerParameters.put("User-Agent", "Manzan/1.0");
for(Entry<String, String> parmEntry : _parameters.entrySet()) {
Expand All @@ -29,10 +29,10 @@ public static HttpDestination get(final String _name, final String _url, final S
uriParameters.put(parmEntry.getKey(), parmEntry.getValue());
}
}
return new HttpDestination(_name, _url, _format, uriParameters, headerParameters);
return new HttpDestination(_name, _type, _url, _format, uriParameters, headerParameters);
}
private HttpDestination(final String _name, final String _url, final String _format, Map<String, String> _uriParams, Map<String, Object> _headerParams) {
super(_name, "http", _url.replaceFirst("^http://", ""), _format, _uriParams, _headerParams);
private HttpDestination(final String _name, String _type, final String _url, final String _format, Map<String, String> _uriParams, Map<String, Object> _headerParams) {
super(_name, _type, _url.replaceFirst("^http(s)?://", ""), _format, _uriParams, _headerParams);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Many other destinations will be available. Examples include:
- [Google Pub/Sub](http://cloud.google.com/pubsub)
- [Grafana Loki](https://grafana.com/oss/loki/)
- HTTP endpoints (REST, etc) ✅
- HTTPS endpoints (REST, etc)
- HTTPS endpoints (REST, etc)
- [Internet of Things (mqtt)](https://www.eclipse.org/paho/)
- [Kafka](http://kafka.apache.org)
- [Mezmo](http://mezmo.com)
Expand Down
7 changes: 6 additions & 1 deletion docs/config/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ Here are the requirements for each section.

These are optional properties available on all types:

* `format` can be used to define a nicer messages to be sent to the destination
* `format` can be used to define a nicer messages to be sent to the destination.\
For file events we have the following variables available: FILE_DATA, FILE_NAME, FILE_PATH.\
For watch events we have the following variables available: SESSION_ID, MESSAGE_ID, MESSAGE_TYPE, SEVERITY, JOB, SENDING_USRPRF, SENDING_PROGRAM_NAME, SENDING_MODULE_NAME, SENDING_PROCEDURE_NAME, MESSAGE_TIMESTAMP, MESSAGE.\
\
By specifying the variable in your format string surrounded by dollar signs, the variables value will be replaced in your format string. Ex. For a file `a.txt` that received the data `hello world` the format string `Data: $FILE_DATA$, Name: $FILE_NAME$` will evaluate to `Data: hello world, Name: a.txt`. `format` can be provided in both data sources and destinations.

* `enabled` is a boolean (`true` or `false`) so a data source can be defined but disabled

```ini
Expand Down
19 changes: 18 additions & 1 deletion docs/config/dests.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ type=<type>

# other properties for <id> here..
```
As well, each section can provide `format` as an optional type.

## Available types

Some types have additional properties that they required.
Some types have additional properties that they require.

| id | Description | Required properties | Optional properties |
|------------------|---------------------------------|------------------------------------------------------------| |
Expand All @@ -27,6 +28,7 @@ Some types have additional properties that they required.
| `smtp`/`smtps` | Sent data via email | * `server` <br> * `subject` <br> * `to` <br> * `from` <br> | * `port` |
| `sentry` | Send data into Sentry | * `dsn` | |
| `twilio` | Send via SMS | * `sid` <br> * `token` <br> * `to` <br> * `from` | |
| `http`/`https` | Send data via http/https | * `url` | * `httpMethod` <br> * `x` where x is any query parameter |

### Example

Expand Down Expand Up @@ -57,4 +59,19 @@ from=+x
type=slack
channel=open-source-system-status
webhook=https://hooks.slack.com/services/TA3EF58G4...

[myLocalHttpServer]
type=http
url=http://localhost:3000
a=54
b=heybuddy
httpMethod=POST
format={"message": "$FILE_DATA$"}

[myProdServer]
type=https
url=https://production.com
foo=bar
httpMethod=POST
format={"message": "$FILE_DATA$", "path": "$FILE_PATH$", "name": "$FILE_NAME$"}
```

0 comments on commit a981da3

Please sign in to comment.