Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Commit

Permalink
Use endpoints for Harold HTTP.
Browse files Browse the repository at this point in the history
This extra flexibility allows us to configure additional options like
SSL, UNIX sockets, etc.
  • Loading branch information
spladug committed Sep 19, 2014
1 parent 5cf0445 commit 1ab8048
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 4 additions & 2 deletions README.md
Expand Up @@ -25,9 +25,11 @@ options follows.
The HTTP plugin provides a general-purpose service that other plugins can
use to receive notifications. It doesn't do anything in itself.

### port
### endpoint

A Twisted endpoint description for the server. e.g. `tcp:8080`.

The port to accept HTTP requests on.
See also: http://twistedmatrix.com/documents/13.1.0/api/twisted.internet.endpoints.serverFromString.html

### secret

Expand Down
10 changes: 8 additions & 2 deletions harold/plugins/http.py
@@ -1,12 +1,14 @@
from twisted.web import resource, server
from twisted.application import internet
from twisted.internet import reactor
from twisted.internet.endpoints import serverFromString

from harold.plugin import Plugin
from harold.conf import PluginConfig, Option


class HttpConfig(PluginConfig):
port = Option(int, default=80)
endpoint = Option(str)
secret = Option(str)


Expand All @@ -32,8 +34,12 @@ def make_plugin(config):
site = server.Site(root)
site.displayTracebacks = False

endpoint = serverFromString(reactor, http_config.endpoint)
service = internet.StreamServerEndpointService(endpoint, site)

plugin = Plugin()
plugin.root = harold
plugin.secret = http_config.secret
plugin.add_service(internet.TCPServer(http_config.port, site))
plugin.add_service(service)

return plugin

0 comments on commit 1ab8048

Please sign in to comment.