# Buggy code
def create(transport, path, config):
    personality = transport.worker.personality
    personality.WEB_SERVICE_CHECKERS["webhook"](personality, config)

    # create a vanilla session: the webhook will use this to inject events
    #
    webhook_session_config = ComponentConfig(realm=config["realm"], extra=None)
    webhook_session = ApplicationSession(webhook_session_config)

    # add the webhook session to the router
    #
    transport._worker._router_session_factory.add(
        webhook_session, authrole=config.get("role", "anonymous")
    )

    # now create the webhook Twisted Web resource
    #
    resource = WebhookResource(config.get("options", {}), webhook_session)

    return RouterWebServiceWebhook(transport, path, config, resource)


# Traceback (builtins.TypeError)
2019-05-18T14:50:35+0000 [Router         18] Starting "publisher" Web service on path "pub" of transport "transport001" <crossbar.worker.router.RouterController.start_web_transport_service>
2019-05-18T14:50:35+0000 [Router         18] RouterController.onUserError(): "TypeError: add() missing 1 required positional argument: 'router'"
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 1613, in unwindGenerator
return _cancellableInlineCallbacks(gen)
File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 1529, in _cancellableInlineCallbacks
_inlineCallbacks(None, g, status)
File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
result = g.send(result)
File "/usr/local/lib/python3.7/site-packages/crossbar/worker/router.py", line 844, in start_web_transport_service
webservice = yield maybeDeferred(webservice_factory.create, transport, path, config)
--- <exception caught here> ---
File "/usr/local/lib/python3.7/site-packages/crossbar/worker/router.py", line 844, in start_web_transport_service
webservice = yield maybeDeferred(webservice_factory.create, transport, path, config)
File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 151, in maybeDeferred
result = f(*args, **kw)
File "/usr/local/lib/python3.7/site-packages/crossbar/webservice/rest.py", line 59, in create
authrole=config.get('role', 'anonymous'))
builtins.TypeError: add() missing 1 required positional argument: 'router'

2019-05-18T14:50:35+0000 [Controller      1] Could not start node: Traceback (most recent call last):
--- <exception caught here> ---
File "/usr/local/lib/python3.7/site-packages/crossbar/node/node.py", line 375, in start
yield self.personality.Node.boot(self)
File "/usr/local/lib/python3.7/site-packages/crossbar/node/node.py", line 498, in boot_from_config
yield d
File "/usr/local/lib/python3.7/site-packages/crossbar/node/node.py", line 475, in configure_worker
yield config_fn(worker_logname, worker_id, worker)
File "/usr/local/lib/python3.7/site-packages/crossbar/node/node.py", line 661, in _configure_native_worker_router
options=CallOptions())
autobahn.wamp.exception.ApplicationError: ApplicationError(error=<wamp.error.runtime_error>, args=["add() missing 1 required positional argument: 'router'"], kwargs={}, enc_algo=None, callee=None, callee_authid=$
one, callee_authrole=None, forward_for=None)

# Fixed code
def create(transport, path, config):
    personality = transport.worker.personality
    personality.WEB_SERVICE_CHECKERS["webhook"](personality, config)

    # create a vanilla session: the webhook will use this to inject events
    #
    webhook_session_config = ComponentConfig(realm=config["realm"], extra=None)
    webhook_session = ApplicationSession(webhook_session_config)

    # add the webhook session to the router
    #
    router = transport._worker._router_session_factory._routerFactory._routers[
        config["realm"]
    ]
    transport._worker._router_session_factory.add(
        webhook_session, router, authrole=config.get("role", "anonymous")
    )

    # now create the webhook Twisted Web resource
    #
    resource = WebhookResource(config.get("options", {}), webhook_session)

    return RouterWebServiceWebhook(transport, path, config, resource)