Commit Graph

98 Commits

Author SHA1 Message Date
Tom Christie c504323eaf
Default to empty body on responses (#208) 2018-11-09 17:59:58 +00:00
Tom Christie 7455fd1f47
URL reconstruction fix (#204)
* Version 0.8.2

* Fix URL reconstruction
2018-11-09 13:39:51 +00:00
赖信涛 8e30f073f0 Do not read file for HEAD method on StaticFiles (#176)
* Do not read file for HEAD method on StaticFiles

* bugfix left in FileResponse

* add test for StaticFiles HEAD method

* restore aiofiles'open after testcase

* format code using black

* Send "http.response.body" instead of disconnect.

body default to b"";
more_body default to False;

fix testcase.

* rebase master, revert background task back

* update param name, send_header_only -> method

* No need to instantiate a new Request, just use scope

* style code using black
2018-11-08 16:59:00 +00:00
Tom Christie 2ef21f49c9
Jinja2 (#198)
* Use jinja2 for a default template configuration

* Add release notes
2018-11-08 16:14:14 +00:00
Tom Christie 3faded4f26
Remove redundant test cases 2018-11-08 12:33:58 +00:00
Jesse Braham a7e0af0a98 Implement session expiry with configurable maximum age (#186)
* Set a maximum age for sessions

* Test session expiry for full coverage

* Fix mypy error

* Handle old-style sessions (ie. no timestamp)
2018-11-08 11:59:27 +00:00
Tom Christie 9f3dcb7d2b
Rejig ExceptionMiddleware and ServerErrorMiddleware (#193)
* Rejig ExceptionMiddleware and ServerErrorMiddleware

* Tweak DebugMiddleware implementation

* Support custom 500 handlers

* Exception handling updates
2018-11-08 11:59:15 +00:00
Alexander Botello 150c7092e5 StaticFiles will check if directory exists upon instantiation (#195)
* Add check_dir parameter

* Add test coverage for check_dir

* Update documentation

* linting

* Remove extra space
2018-11-08 09:33:20 +00:00
Tom Christie 3e2e3430d1
Add `@app.middleware(...)` decorator (#183)
* Add @app.middleware() decorator

* Linting

* Drop erronous check-in

* Type hinting for BaseHTTPMiddleware
2018-11-06 12:19:52 +00:00
Tom Christie 3c7573715d
Add www_redirect behavior to TrustedHostsMiddleware (#181) 2018-11-05 11:38:20 +00:00
zya-performance 552e0f6f2d adds background task param to StreamingResponse and FileResponse (#167)
*  adds background task param to StreamingResponse

* allows FileResponse to run a background task after last bye is sent

* test StreamingResponse and FileResponse with background task

* linted

* added a blank line to match CI expectations
2018-11-05 11:38:05 +00:00
Tom Christie 23c009ca53
Finesse mount routing (#173)
* Finesse mount routing

* Add redirect_slashes behavior

* Add redirect_slashes behavior

* Support url_path_for, with mounted apps.
2018-11-05 11:11:35 +00:00
Tom Christie 5584568f8a
Drop add_graphql_route, in favor of more consistent API style (#170) 2018-11-01 12:52:16 +00:00
Tom Christie 81c4306a3a
Add OpenAPIResponse, API Schema docs, etc... (#171) 2018-11-01 12:52:03 +00:00
Tom Christie de010e7796
Return strings from `url_path_for` (#169)
Schema generation & return strings from `url_path_for`
2018-11-01 10:40:08 +00:00
Tom Christie 96c51c959a
Routing tweaks (#164)
* Ensure url_path_for works with Mount('/{some_path_params}')

* Fix Router(default=) argument

* Support partial matches on routing, to support handlers with same path, but different methods.

* Run sync views in threadpool

* Use default executor for WSGI middleware
2018-10-30 16:08:05 +00:00
Tom Christie 244916e1de
Support clearing sessions (#158)
* Use isort for consistent import ordering

* Add SessionMmiddleware support

* Add SessionMiddleware support

* Support clearing sessions

* Version 0.6.2
2018-10-29 16:43:40 +00:00
Tom Christie 87da226f1c
Session middleware (#157)
* Use isort for consistent import ordering

* Add SessionMmiddleware support

* Add SessionMiddleware support
2018-10-29 16:16:51 +00:00
Tom Christie bcf876c686
Use isort for consistent import ordering (#156) 2018-10-29 14:46:42 +00:00
Tom Christie ee4732f385
BaseHTTPMiddleware (#155)
* Support app.url_path_for and request.url_for

* Minor tweak to release notes

* Added BaseHTTPMiddleware
2018-10-29 13:02:43 +00:00
Tom Christie c047fe4e75
Support app.url_path_for and request.url_for (#153) 2018-10-29 11:14:42 +00:00
Tom Christie 8da0f00fe7
Routing interface (#144)
* Path -> Route, PathPrefix -> Mount

* Route, WebSocketRoute, Mount

* Use Route(endpoint=...), not Route(app=...)

* Bare minimum docs update

* Add url_for

* request.path_params and session.path_params

* Version 0.6.0
2018-10-29 09:22:45 +00:00
Tom Christie f53b172f8a
Domain wildcards for trusted host (#151)
* Support domain wildcards with TrustedHostMiddleware

* Support domain wildcards with TrustedHostMiddleware

* Include domain wildcards in TrustedHostMiddleware docs
2018-10-29 09:22:13 +00:00
Alexander Botello cdb08bc644 Drop support for `StaticFile` (#145)
* Add runtime checks inside FileResponse w/ tests

* Drop support of StaticFile

* update documentation
2018-10-28 18:04:17 +00:00
Ryan Kaskel a32ea0a8e8 Return an iterator over keys for Headers and QueryParams (#142) 2018-10-26 13:29:25 +01:00
Alexander Botello 3ca34ce0a2 Support a routing interface for `Router` (#143)
* Add a routing interface to Router

* Starlette class now wraps routing functionality from Router

* No need to pass in empty list

* Add missing test coverage

* black that one file i always forget
2018-10-26 10:30:54 +01:00
Alexander Botello bc26ab3319 Support either `cleanup` or `shutdown` in ASGI lifespan messages (#134)
* support either cleanup or shutdown in ASGI message

* change event_type in tests

* update docs

* fix typo

* keep  as event_type for now

* exclude line 65

* blackify

* replace cleanup with shutdown in docs
2018-10-22 15:08:04 +01:00
Tom Christie 137c2ab70e Add 'app.add_graphql_route()' 2018-10-18 16:58:49 +01:00
Tom Christie c0f9f60ae9 Add graphiql support 2018-10-18 15:24:26 +01:00
Tom Christie 315a21be85
GraphQL support (#126)
* GraphQL support

* GraphQL support

* Run GraphQL queries inside a threadpool

* Support AsyncioExecutor

* GraphQL error formatting

* Docs for GraphQL support
2018-10-18 14:45:18 +01:00
Tom Christie 67b8d71601
Revisit WebSocket status codes (#119) 2018-10-18 08:47:04 +01:00
Alexander Botello b0763469ff Support a function-based interface for adding events on LifespanHandler (#124)
* Add function interface to lifespanhandler

* function interface accessible added to applications

* Add test for add_event_handler
2018-10-18 08:43:21 +01:00
Tom Christie 860fdf6c8b
Add WSGI middleware (#120)
* Add WSGI middleware

* Fix for WSGI middleware tests
2018-10-17 16:54:02 +01:00
Tom Christie 2b2c07078c Fix Headers repr 2018-10-17 14:01:26 +01:00
Tom Christie 4afb143f02 Add QueryParams(items=...) 2018-10-17 13:33:36 +01:00
Tom Christie 6dd6dd6f0a
Add scope=... arguments to Headers, QueryParams, URL (#118) 2018-10-17 12:31:53 +01:00
Jeff Buttars eed466abbc Add http and websocket status codes with descriptive variables (#43)
* Add status.py for http and websocket status code with descriptive
variable names.

* Fix import of status

* Add status usage to tests

* change wsconnect to websocket_connect

* Update with master
2018-10-17 12:31:20 +01:00
Tom Christie c50460fbb9
Add final missing annotations, and enable '--disallow-untyped-defs' (#115)
* fix(dataStructures): missing annotations added

* fix(requests.py): annotations added

* fix(Annotations): wrong annotations fixed on datastructures and requests modules.

* fix(Missing annotation): missing annotations added on testclient module.

* fix(testclient): annotations fixed

* minor tweaks

* fix(testclient): Session request method fixed. WIP _ASGIAdapter send method

* fix(testclient): small tweaks

* Switch on --disallow-untyped-defs when testing with mypy
2018-10-16 15:56:28 +01:00
Tom Christie 097152be5a
Add GZip middleware (#111) 2018-10-15 12:08:10 +01:00
Tom Christie 77d995d7c8
Handle server: None and scheme: None cases in URL scope (#109) 2018-10-15 09:36:05 +01:00
Tom Christie c43a070eed
Form parsing (#102)
* Work towards MultiPartParser

* Work towards MultiPartParser

* Add test for multipart files

* MultiPart parsing

* Fix for large multipart messages

* Add python-multipart to docs

* Add python-multipart to 'pip install starlette[full]'

* Add FormParser

* Add docs for request.form()

* Drop mypy momentarily
2018-10-12 18:15:04 +01:00
Alex Botello 7a0f89abb8 Respond to credentialed requests with specific origin (#105)
* Respond with specific origin instead of wildcard for credentialed requests

* Add test case for credentialed standard request

* Add tests for setting vary header
2018-10-12 09:46:10 +01:00
Tom Christie 58898a729c
Add explicit UJSONResponse (#99) 2018-10-10 17:04:12 +01:00
Tom Christie 139753f857
Add support for `app.on_event("startup")` and `app.on_event("cleanup")`. (#98)
* Push black linting into ./scripts/test Fix some annotations etc.

* Skip black on 3.7

* Fix script

* Blergh. Shell equality tests are weird

* Attempt to fix equality check

* Document 'allow_origin_regex'

* Support app.on_event('startup') and app.on_event('cleanup')

* Nicer decorator handling for on_event

* Add documentation for app.on_event()
2018-10-09 15:47:51 +01:00
Tom Christie d505abc0b5
Don't partially enforce CORS server-side (#93)
* Don't partially enforce CORS server-side

* Comment on CORS enforcement
2018-10-09 10:07:51 +01:00
Alex Botello fc6883aa0a Support `allow_origin_regex` in CORSMiddleware (#92)
* Add tests for allow_origin_regex

* Add support for allow_origin_regex

* black linting

* refactor if statement on line 76

* Invert conditional to a more readable syntax
2018-10-09 09:35:08 +01:00
Jordan Eremieff d1ba5d6722 Cookies (#86)
* Initial cookies support for response/request classes

* Type hint

* Drop .get_cookie() from request class
2018-10-06 13:08:16 +01:00
Tom Christie c98c15005e
Middleware and CORS support (#83)
* Tweaks to URL datastructure

* Linting

* Add Middleware

* Type annotations

* CORS support

* Add CORS support

* Fix code example
2018-10-05 16:38:02 +01:00
Tom Christie 19670ae2cd
Middleware (#82)
* Tweaks to URL datastructure

* Linting

* Add Middleware
2018-10-05 12:04:11 +01:00
Tom Christie 94044e5991
Tweaks to URL datastructure (#81)
* Tweaks to URL datastructure

* Linting
2018-10-05 11:29:06 +01:00