Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
15c1ae45
Commit
15c1ae45
authored
6 years ago
by
Richard van der Hoff
Browse files
Options
Downloads
Patches
Plain Diff
Docstrings for BaseFederationServlet
... to save me reverse-engineering this stuff again.
parent
8a86d7ea
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/federation/transport/server.py
+47
-0
47 additions, 0 deletions
synapse/federation/transport/server.py
with
47 additions
and
0 deletions
synapse/federation/transport/server.py
+
47
−
0
View file @
15c1ae45
...
@@ -190,6 +190,41 @@ def _parse_auth_header(header_bytes):
...
@@ -190,6 +190,41 @@ def _parse_auth_header(header_bytes):
class
BaseFederationServlet
(
object
):
class
BaseFederationServlet
(
object
):
"""
Abstract base class for federation servlet classes.
The servlet object should have a PATH attribute which takes the form of a regexp to
match against the request path (excluding the /federation/v1 prefix).
The servlet should also implement one or more of on_GET, on_POST, on_PUT, to match
the appropriate HTTP method. These methods have the signature:
on_<METHOD>(self, origin, content, query, **kwargs)
With arguments:
origin (unicode|None): The authenticated server_name of the calling server,
unless REQUIRE_AUTH is set to False and authentication failed.
content (unicode|None): decoded json body of the request. None if the
request was a GET.
query (dict[bytes, list[bytes]]): Query params from the request. url-decoded
(ie,
'
+
'
and
'
%xx
'
are decoded) but note that it is *not* utf8-decoded
yet.
**kwargs (dict[unicode, unicode]): the dict mapping keys to path
components as specified in the path match regexp.
Returns:
Deferred[(int, object)|None]: either (response code, response object) to
return a JSON response, or None if the request has already been handled.
Raises:
SynapseError: to return an error code
Exception: other exceptions will be caught, logged, and a 500 will be
returned.
"""
REQUIRE_AUTH
=
True
REQUIRE_AUTH
=
True
def
__init__
(
self
,
handler
,
authenticator
,
ratelimiter
,
server_name
):
def
__init__
(
self
,
handler
,
authenticator
,
ratelimiter
,
server_name
):
...
@@ -204,6 +239,18 @@ class BaseFederationServlet(object):
...
@@ -204,6 +239,18 @@ class BaseFederationServlet(object):
@defer.inlineCallbacks
@defer.inlineCallbacks
@functools.wraps
(
func
)
@functools.wraps
(
func
)
def
new_func
(
request
,
*
args
,
**
kwargs
):
def
new_func
(
request
,
*
args
,
**
kwargs
):
"""
A callback which can be passed to HttpServer.RegisterPaths
Args:
request (twisted.web.http.Request):
*args: unused?
**kwargs (dict[unicode, unicode]): the dict mapping keys to path
components as specified in the path match regexp.
Returns:
Deferred[(int, object)|None]: (response code, response object) as returned
by the callback method. None if the request has already been handled.
"""
content
=
None
content
=
None
if
request
.
method
in
[
"
PUT
"
,
"
POST
"
]:
if
request
.
method
in
[
"
PUT
"
,
"
POST
"
]:
# TODO: Handle other method types? other content types?
# TODO: Handle other method types? other content types?
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment