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.
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.
C.f. what I did for Sydent here: https://github.com/matrix-org/sydent/blob/143a22520b974ac63987de8dc048891071f299e4/sydent/http/servlets/__init__.py#L177-L181
| 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.
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.
Does jsonwrap refer to the decorators below?
There was a problem hiding this comment.
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.