Make the application ``Request`` class overridable. (#61)
This commit is contained in:
parent
e6fa299d1e
commit
cc4901241f
|
@ -9,6 +9,10 @@
|
|||
that include it.
|
||||
- Fix incorrect type signature for the EnvironDict type.
|
||||
|
||||
#### Changes
|
||||
|
||||
- Make the application ``Request`` class overridable.
|
||||
|
||||
### v0.8.2 (2021-03-21)
|
||||
|
||||
#### Fixes
|
||||
|
|
|
@ -252,6 +252,8 @@ class JetforceApplication:
|
|||
rate_limiter: typing.Optional[RateLimiter]
|
||||
routes: typing.List[typing.Tuple[RoutePattern, RouteHandler]]
|
||||
|
||||
request_class: typing.Type[Request] = Request
|
||||
|
||||
def __init__(self, rate_limiter: typing.Optional[RateLimiter] = None):
|
||||
self.rate_limiter = rate_limiter
|
||||
self.routes = []
|
||||
|
@ -260,7 +262,7 @@ class JetforceApplication:
|
|||
self, environ: EnvironDict, send_status: WriteStatusCallable
|
||||
) -> ApplicationResponse:
|
||||
try:
|
||||
request = Request(environ)
|
||||
request = self.request_class(environ)
|
||||
except Exception:
|
||||
send_status(Status.BAD_REQUEST, "Invalid URL")
|
||||
return
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import json
|
||||
import os
|
||||
|
||||
print("20 application/json")
|
||||
print(json.dumps(dict(os.environ)))
|
||||
|
|
Loading…
Reference in New Issue