-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add utils to build web servlets #11
Conversation
Would it make more sense to use the |
Not sure, I feel like Synapse's |
Yeah, that's fair. I guess I like the way |
|
||
def json_servlet_async(fn: Callable[..., JsonDict]) -> Callable[..., int]: | ||
async def render( | ||
fn: Callable[..., Any], self: Any, request: Request, **kwargs: Any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We await and json encode the return from fn
below, so we probably want it to return Awaitable[JsonDict]
?
fn: Callable[..., Any], self: Any, request: Request, **kwargs: Any | |
fn: Callable[..., Awaitable[JsonDict]], self: Any, request: Request, **kwargs: Any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn: The handler to run. | ||
self: The current object. | ||
request: The request to process. | ||
args: The arguments to pass to the function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the *args
argument missing?
|
||
class MatrixRestError(Exception): | ||
""" | ||
Handled by the jsonwrap wrapper. Any servlets that don't use this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does jsonwrap
refer to the decorators below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Err, yes, I forgot to rename it here.
After having progressed a bit more into the content scanner rewrite, I'm not sure this is how I want it this to look like. I'll revisit once I'm back from holidays. |
Closing this as we'll probably want to go another way. |
Lifted almost verbatim from https://github.com/matrix-org/sydent/blob/main/sydent/http/servlets/__init__.py
The reason behind this PR is that I'm looking at rewriting https://github.com/matrix-org/matrix-content-scanner in Python and I realised a lot of code to help creating and managing web servlets lives in Sydent, and I'd rather move it in here than copy it over to a new project.
I haven't added tests, mostly because I'm not sure how to test this kind of things.