File: index.md

package info (click to toggle)
golang-github-nicholas-fedor-shoutrrr 0.8.17-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,332 kB
  • sloc: sh: 61; makefile: 5
file content (81 lines) | stat: -rw-r--r-- 2,795 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Generic

The Generic service can be used for any target that is not explicitly supported by Shoutrrr, as long as it
supports receiving the message via a POST request.
Usually, this requires customization on the receiving end to interpret the payload that it receives, and might
not be a viable approach.

Common examples for use with service providers can be found under [examples](../../examples/generic-webhook/index.md).

## Custom headers

You can add additional HTTP headers to your request by adding query variables prefixed with `@` (`@key=value`).

Using

```url
generic://example.com?@acceptLanguage=tlh-Piqd
```

would result in the additional header being added:

```http
Accept-Language: tlh-Piqd
```

## JSON template

By using the built in `JSON` template (`template=json`) you can create a generic JSON payload. The keys used for `title` and `message` can be overriden
by supplying the params/query values `titleKey` and `messageKey`.

!!! example
    ```json
    {
        "title": "Oh no!",
        "message": "The thing happened and now there is stuff all over the area!"
    }
    ```

### Custom data fields

When using the JSON template, you can add additional key/value pairs to the JSON object by adding query variables prefixed with `$` (`$key=value`).

!!! example
    Using `generic://example.com?$projection=retroazimuthal` would yield:
    ```json
    {
        "title": "Amazing opportunities!",
        "message": "New map book available for purchase.",
        "projection": "retroazimuthal"
    }
    ```

## Shortcut URL

You can just add `generic+` as a prefix to your target URL to use it with the generic service, so

```url
https://example.com/api/v1/postStuff
```

would become

```url
generic+https://example.com/api/v1/postStuff
```

!!! Note
    Any query variables added to the URL will be escaped so that they can be forwarded to the remote server. That means that you cannot use `?template=json` with the  `generic+https://`, just use `generic://` instead!

## Forwarded query variables

All query variables that are not listed in the [Query/Param Props](#queryparam_props) section will be forwarded to the target endpoint.
If you need to pass a query variable that _is_ reserved, you can prefix it with an underscore (`_`).

!!! Example
    The URL `generic+https://example.com/api/v1/postStuff?contenttype=text/plain` would send a POST message to `https://example.com/api/v1/postStuff` using the `Content-Type: text/plain` header.
    If instead escaped, `generic+https://example.com/api/v1/postStuff?_contenttype=text/plain` would send a POST message to `https://example.com/api/v1/postStuff?contenttype=text/plain` using the `Content-Type: application/json` header (as it's the default).

## URL Format

--8<-- "docs/services/generic/config.md"