Altair Bueno
fb21561616
Add WithRejection
( #1262 )
...
* new(axum-extra): Added `WithRejection` base impl
Based on @jplatte's version (https://github.com/tokio-rs/axum/issues/1116#issuecomment-1215048273 ), with slight changes
- Using `From<E::Rejection>` to define the trait bound on a more concise way
- Renamed variables to something more meaningfull
* revert(axum-extra): Removed `with_rejection` feat
* ref(axum-extra): Replaced `match` with `?`
* tests(axum-extra): Added test for `WithRejection`
* examples: Replaced custom `Json` extractor with `WithRejection`
* docs(axum-extra): Added doc to `WithRejection`
* fmt(cargo-check): removed whitespaces
* fmt(customize-extractor-error): missing fmt
* docs(axum-extra): doctest includes `Handler` test
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
* docs(axum-extra):` _ `-> `rejection`
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
* docs(axum-extra): fixed suggestions
* fix(axum-extra): `WithRejection` manual trait impl
* revert(customize-extractor-error): Undo example changes
refs: d878eede18
, f9200bf4b9
* example(customize-extractor-error): Added reference to `WithRejection`
* docs(axum-extra): Removed `customize-extractor-error` reference
* fmt(axum-extra): cargo fmt
* docs(axum-extra): Added `WithRejection` to CHANGELOG.md
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
2022-08-17 07:59:25 +00:00
kkocdko
a8e80bcb97
Improve performance in low-level-rustls example ( #1254 )
2022-08-12 11:57:59 +00:00
David Pedersen
d9ef24c5ff
Replace async-graphql with link to async-graphql's own examples ( #1234 )
...
* Replace async-graphql with link to async-graphql's own examples
* exclude async-graphql directory
* does this fix it?
* apparently this needs to be sorted as well
* Update .github/workflows/CI.yml
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2022-08-09 14:56:50 +00:00
Jonas Platte
f0f60681ef
Fix intra-doc links on docs.rs ( #1205 )
...
* Use version 2 of Cargo's feature resolver
* Increase minimum version of tungstenite
Tungstenite 0.17.1 has a higher MSRV, and there should be no reason to
use it over 0.17.2.
* Clean up and fix MSRV CI job
* Fix some intra-doc links not resolving correctly on docs.rs
* Bump minimum version of tower
… to avoid dependencies with a broken minimum-versions chain.
2022-07-28 19:14:31 +02:00
Péter Leéh
6ff1c2111e
Fix comment typos in stream-to-file example ( #1200 )
2022-07-27 11:10:00 +00:00
Lex Cao
3c0778b16d
Add an example for head request ( #1189 )
...
As #84 add get-head request, adding an example.
2022-07-26 20:19:03 +02:00
Sugih Jamin
4558671a0b
Redirect HTTP to HTTPS in tls-rustls
example ( #1166 )
2022-07-23 10:23:40 +02:00
Kartavya Vashishtha
cf09f62a1a
Add example for multiple listen addrs ( #1179 )
2022-07-20 18:33:12 +00:00
azzamsa
a3eaa332e4
test: use ready()
and call()
to avoid using clone()
( #1176 )
2022-07-20 12:19:15 +00:00
Allan
928d60fbba
Fix two comment typos ( #1172 )
2022-07-18 17:16:38 +00:00
Jonas Platte
1812c4dfe8
Remove explicit TryFrom, TryInto imports ( #1099 )
2022-06-17 18:36:49 +00:00
David Pedersen
93251fa203
Bump MSRV to 1.56 and update to the 2021 edition ( #1098 )
2022-06-17 20:11:35 +02:00
David Pedersen
fd70f81c46
More robust asset paths in examples ( #1090 )
...
* More robust asset paths in examples
* Update examples/low-level-rustls/src/main.rs
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
* format
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2022-06-15 22:42:49 +02:00
Shing
cbb2e8a244
Fix missing assets in websockets example ( #1089 )
...
* fix missing assets running websockets example
* Update examples/websockets/src/main.rs
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
* remove unnecessary mut
* fix cargo fmt
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
2022-06-15 10:04:44 +02:00
David Pedersen
968ee44631
Sort dependencies in Cargo.toml
s ( #1076 )
...
* sort dependencies
* check sorted deps on CI
* this should fail
* does caching matter?
* fix sorting
2022-06-10 08:59:17 +02:00
David Pedersen
be71e7b286
Fix vulnerability in example-stream-to-file example ( #1040 )
...
* Fix vulnerability in example-stream-to-file example
* Save files to separate directory
2022-05-17 12:38:15 +02:00
Jonas Platte
591434778f
Slightly simplify CORS example ( #1027 )
2022-05-12 11:36:57 +02:00
David Pedersen
7774cfd1f7
Update static file server example ( #1011 )
2022-05-08 19:52:34 +00:00
takumi
4b384fa01c
upgrade uuid from 0.8 to 1.0 ( #995 )
2022-05-05 07:48:49 +02:00
David Pedersen
d1043db254
Fix driving readiness for example-rest-grpc-multiplex
( #988 )
2022-05-03 09:21:49 +00:00
takumi
4ff5e409e3
Add rest and grpc example ( #967 )
...
* Add rest and grpc example
* remove needless dependencies
* Apply suggestions from code review
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
* Update examples/rest-grpc-multiplex/src/main.rs
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
* Update examples/rest-grpc-multiplex/src/main.rs
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
* Update examples/rest-grpc-multiplex/src/multiplex_service.rs
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
* Update examples/rest-grpc-multiplex/Cargo.toml
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
* Update examples/rest-grpc-multiplex/src/multiplex_service.rs
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
* clean noisy code
* fix nitpicks
* missing newline
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
2022-05-02 15:52:55 +00:00
David Pedersen
1fe4558362
Move examples to separate workspace ( #978 )
...
* Move examples to separate workspace
* update commands to run examples
* remove debug
2022-04-29 18:53:41 +02:00
David Pedersen
79f6cde3b1
Update to tower-http 0.3.0 ( #965 )
...
* Update to tower-http 0.3.0
* changelog link
2022-04-25 14:59:16 +00:00
Slava
0313c08dc9
helpful note about posting with CORS ( #938 )
2022-04-17 08:13:22 +00:00
zys864
a237edb7c3
Fix example-unix-domain-socket
on non-unix platforms ( #919 )
...
* remove unused `axum`'s dependency:`tokio-util`
* fix `examples/todos`'s `async fn todos_index` iter_overeager_cloned
* Add docs to `/examples/async-graphql`, just like other xamples.
* remove `examples/async-graphql` unused dependencies `tracing-subscriber` and `trace`
* `examples/chat` deps `trace` and `tracing-subscriber` never be used. Add trace `debug` to `chat`
* remove `examples/print-request-response` unused dependency `axum-extra`
* remove `examples/prometheus-metrics` unused dependency `axum-extra`
* remove `examples/reverse-proxy` unused dependencies `tracing-subscriber` and `trace`
* `examples/chat` fmt fix
* fix `example-unix-domain-socket` compile error on not-unix platforms
Co-authored-by: zys864 <zys864@qq.com>
Co-authored-by: zys864 <zys864@gmail.com>
2022-04-08 11:29:52 +02:00
Simon Sellar
59007d6111
Minor fixup of websocket example logging text. ( #910 )
2022-04-06 10:33:34 +00:00
David Pedersen
2270cf7b3e
Add "stream to file" example ( #903 )
...
* Add "stream to file" example
* add title tag
2022-04-03 12:28:29 +02:00
David Pedersen
21552fe434
Remove bound from into_make_service_with_connect_info
( #892 )
...
Fixes #859
2022-03-31 16:49:49 +00:00
Evan Schwartz
3084dc10ca
Accept &str
for Redirect
( #889 )
...
* Accept &str for Redirect
* Fix doc example
* fix more docs examples
* update changelog
* fix changelog label
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
2022-03-31 10:03:06 +02:00
David Pedersen
437fe5b931
Make status codes for JsonRejection
more precise ( #868 )
...
* Fix status codes for `JsonRejection` rejections
Fixes #865
* Apply suggestions from code review
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2022-03-18 16:53:39 +01:00
David Pedersen
33ee55e52c
Add example for consuming request body in middleware and extractor ( #861 )
2022-03-18 15:41:38 +00:00
Jonas Platte
79b94b9bd6
Replace set_var usage in examples ( #829 )
...
* examples: Fix inconsistent toml formatting
* examples: Replace set_var usage
2022-03-06 12:37:00 +01:00
Max Bruckner
99fbd3d32c
Add note about order of extractors in the reverse-proxy example ( #821 )
2022-03-03 22:33:33 +01:00
zys864
768d8a8218
Fix minor issues in some examples ( #806 )
...
* remove unused `axum`'s dependency:`tokio-util`
* fix `examples/todos`'s `async fn todos_index` iter_overeager_cloned
* Add docs to `/examples/async-graphql`, just like other xamples.
* remove `examples/async-graphql` unused dependencies `tracing-subscriber` and `trace`
* `examples/chat` deps `trace` and `tracing-subscriber` never be used. Add trace `debug` to `chat`
* remove `examples/print-request-response` unused dependency `axum-extra`
* remove `examples/prometheus-metrics` unused dependency `axum-extra`
* remove `examples/reverse-proxy` unused dependencies `tracing-subscriber` and `trace`
* `examples/chat` fmt fix
2022-03-01 09:30:09 +00:00
David Pedersen
a2b568c7c1
Implement tower::Layer
for Extension
( #801 )
...
* Implement `tower::Layer` for `Extension`
* changelog
2022-03-01 00:39:22 +01:00
David Pedersen
f12ab072c5
Add IntoResponseParts
( #797 )
...
* Add `IntoResponseParts`
* docs
* Add test
* don't allow overriding body or response
* macroify impls
* re-order things a bit
* Fix tests
* Also allow overriding version
* Move things into separate modules
* docs
* clean up
* fix trybuild test
* remove churn
* simplify buliding response
* fixup test
* fix docs typo
* Use `HeaderValue::from_static`, might be faster
* Bring back `impl IntoResponse` in example
* Remove blanket impl to improve error message
* don't need to set `content-type`
* Apply suggestions from code review
Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
* changelog
Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
2022-02-28 23:04:33 +00:00
zys864
cb168b96fe
fix examples/todos
's async fn todos_index
iter_overeager_cloned ( #794 )
...
* remove unused `axum`'s dependency:`tokio-util`
* fix `examples/todos`'s `async fn todos_index` iter_overeager_cloned
2022-02-25 15:29:23 +01:00
frobiac
8c0926ee5b
examples(jwt): Claims.exp represents a UTC timestamp ( #760 )
...
For the example to work, it should be an epoch value in the future.
See d8a33def00/README.md (L61)
2022-02-15 21:43:31 +00:00
David Pedersen
409a6651f5
Update dependencies ( #753 )
2022-02-12 17:16:14 +00:00
Evgenii
0c16ce7649
fix: typo in a comment in a sqlx-postgres example ( #744 )
2022-02-04 08:14:34 +01:00
David Pedersen
a04fc42d75
Rework middleware docs ( #732 )
...
* rework middleware docs
* Apply suggestions from code review
Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
2022-01-30 20:09:18 +01:00
YuKun Liu
c0473f2b6f
Expand WebSocket example to match
on Message
( #723 )
2022-01-25 15:31:33 +00:00
FlakM
32c9ab3c56
Add sqlx example with migrations ( #722 )
...
* Add sqlx example with migrations
Simple use case for sqlx based on tokio postgres example.
Sqlite database is created on execution in ./target directory
and migrations are then run against it.
* sqlx example uses postgres instead of sqlite3
Also removed migrations and database creation code.
2022-01-25 16:20:00 +01:00
David Pedersen
9004a14302
Move middleware::from_fn
into axum ( #719 )
...
* Move `middleware::from_fn` into axum
* changelog
* fix feature
* Rephrase changelog a bit
2022-01-25 10:19:06 +01:00
David Pedersen
184ea656c0
Change HeaderMap
extractor to clone the headers ( #698 )
...
* Change `HeaderMap` extractor to clone the headers
* fix docs
* changelog
* inline variable
* also add changelog item to axum
* don't list types from axum in axum-core's changelog
* document that `HeaderMap::from_request` clones the headers
* fix typo
* a few more typos
2022-01-23 18:01:52 +01:00
Nick Ashley
9b4232b786
Replace public use of mime crate with &str ( #642 )
...
Replaces `Field::content_type`'s return type with `&str`.
This is a breaking change.
Closes #637
2022-01-23 18:01:52 +01:00
Nick Ashley
007a0e85f2
Use 308 instead of 301 for trailing slash redirects ( #682 )
...
* Use 308 status instead of 301 when redirecting
For redirects resulting from requests to paths with a trailing slash,
use 308 instead of 301 to prevent non-GET requests (POST, PUT, etc) from
being changed to GET.
For example, (assuming a route for /path is defined)...
- Old behavior results in:
POST /path/ -> GET /path
- New behavior results in:
POST /path/ -> POST /path
Fixes #681
* Add deprecation notice to found()
Deprecates found() due to its use of HTTP 302
* rustfmt
* Use dedicated redirect method
Use Redirect::permanent instead of re-implementing its functionality
* Remove deprecated method from example
Replace usages of Redirect:found with Redirect::to and Redirect::temporary as appropriate
* Fix panic in oauth example
Previously the example would panic if a request was made without the
`Cookie` header. Now the user is redirected to the login page as
expected.
* Update CHANGELOG
* Revert pub TypedheaderRejection fields
* Fix clippy lint
* cargo fmt
* Fix CHANGELOG link
* Adhere to implicit line length limit
2022-01-12 15:14:06 +01:00
David Pedersen
6d24a8695f
Add SSE tests ( #652 )
...
* Add SSE tests
* Simplify keep alive test a bit
* More robust keep-alive tests
* rename a bit
2022-01-03 18:48:50 +01:00
Jonas Platte
616a43aaa3
Simplify graceful shutdown ( #673 )
2021-12-28 16:23:07 +01:00
David Pedersen
5698fb8be9
Add metrics example ( #671 )
2021-12-28 15:58:48 +01:00