summaryrefslogtreecommitdiff
path: root/src/mailman/rest/docs/plugins.rst
blob: 737a911c02c9da9959fcf76a198dfd8fc394082c (plain)
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
=========
 Plugins
=========

Plugins can supply REST routes.
::

    >>> dump_json('http://localhost:9001/3.1/plugins')
    entry 0:
        class: mailman.testing.plugin.ExamplePlugin
        configuration:
        enable: True
        http_etag: "..."
        name: example
        path:
    http_etag: "..."
    start: 0
    total_size: 1

    >>> dump_json('http://localhost:9001/3.1/plugins/example')
    example-plugin-reply: yes
    http_etag: "..."

    >>> dump_json('http://localhost:9001/3.1/plugins/example/good')
    good: True
    http_etag: "..."

    >>> dump_json('http://localhost:9001/3.1/plugins/example/bad')
    Traceback (most recent call last):
    ...
    urllib.error.HTTPError: HTTP Error 400: ...

For example this route that presents a counter.
::

    >>> dump_json('http://localhost:9001/3.1/plugins/example/count')
    count: 0
    http_etag: "..."

    >>> call_http('http://localhost:9001/3.1/plugins/example/count',
    ...           {'count':3}, method='POST')
    content-length: 0
    date: ...
    server: ...
    status: 204

    >>> dump_json('http://localhost:9001/3.1/plugins/example/count')
    count: 3
    http_etag: "..."

    >>> call_http('http://localhost:9001/3.1/plugins/example/count',
    ...           method='DELETE')
    content-length: 0
    date: ...
    server: ...
    status: 204

    >>> dump_json('http://localhost:9001/3.1/plugins/example/count')
    count: 0
    http_etag: "..."