Rocket/examples
Sergio Benitez 56c6a96f6a Overhaul URI types.
This is fairly large commit with several entangled logical changes.

The primary change in this commit is to completely overhaul how URI
handling in Rocket works. Prior to this commit, the `Uri` type acted as
an origin API. Its parser was minimal and lenient, allowing URIs that
were invalid according to RFC 7230. By contrast, the new `Uri` type
brings with it a strict RFC 7230 compliant parser. The `Uri` type now
represents any kind of valid URI, not simply `Origin` types. Three new
URI types were introduced:

  * `Origin` - represents valid origin URIs
  * `Absolute` - represents valid absolute URIs
  * `Authority` - represents valid authority URIs

The `Origin` type replaces `Uri` in many cases:

  * As fields and method inputs of `Route`
  * The `&Uri` request guard is now `&Origin`
  * The `uri!` macro produces an `Origin` instead of a `Uri`

The strict nature of URI parsing cascaded into the following changes:

  * Several `Route` methods now `panic!` on invalid URIs
  * The `Rocket::mount()` method is (correctly) stricter with URIs
  * The `Redirect` constructors take a `TryInto<Uri>` type
  * Dispatching of a `LocalRequest` correctly validates URIs

Overall, URIs are now properly and uniformly handled throughout Rocket's
codebase, resulting in a more reliable and correct system.

In addition to these URI changes, the following changes are also part of
this commit:

  * The `LocalRequest::cloned_dispatch()` method was removed in favor of
    chaining `.clone().dispatch()`.
  * The entire Rocket codebase uses `crate` instead of `pub(crate)` as a
    visibility modifier.
  * Rocket uses the `crate_visibility_modifier` and `try_from` features.

A note on unsafety: this commit introduces many uses of `unsafe` in the
URI parser. All of these uses are a result of unsafely transforming byte
slices (`&[u8]` or similar) into strings (`&str`). The parser ensures
that these casts are safe, but of course, we must label their use
`unsafe`. The parser was written to be as generic and efficient as
possible and thus can parse directly from byte sources. Rocket, however,
does not make use of this fact and so would be able to remove all uses
of `unsafe` by parsing from an existing `&str`. This should be
considered in the future.

Fixes #443.
Resolves #263.
2018-07-29 00:17:33 -07:00
..
config Reorganize repository. 2018-06-03 18:44:38 +02:00
content_types Reorganize repository. 2018-06-03 18:44:38 +02:00
cookies Reorganize repository. 2018-06-03 18:44:38 +02:00
errors Reorganize repository. 2018-06-03 18:44:38 +02:00
fairings Reorganize repository. 2018-06-03 18:44:38 +02:00
form_kitchen_sink Reorganize repository. 2018-06-03 18:44:38 +02:00
form_validation Reorganize repository. 2018-06-03 18:44:38 +02:00
handlebars_templates Overhaul URI types. 2018-07-29 00:17:33 -07:00
hello_person Reorganize repository. 2018-06-03 18:44:38 +02:00
hello_world Reorganize repository. 2018-06-03 18:44:38 +02:00
json Reorganize repository. 2018-06-03 18:44:38 +02:00
managed_queue Fix compatibility warnings and errors in examples. 2018-07-25 09:01:29 -06:00
manual_routes Overhaul URI types. 2018-07-29 00:17:33 -07:00
msgpack Reorganize repository. 2018-06-03 18:44:38 +02:00
optional_redirect Reorganize repository. 2018-06-03 18:44:38 +02:00
pastebin Update 'rand' dependency in 'pastebin' example. 2018-07-22 21:59:40 -07:00
query_params Reorganize repository. 2018-06-03 18:44:38 +02:00
ranking Reorganize repository. 2018-06-03 18:44:38 +02:00
raw_sqlite Reorganize repository. 2018-06-03 18:44:38 +02:00
raw_upload Reorganize repository. 2018-06-03 18:44:38 +02:00
redirect Reorganize repository. 2018-06-03 18:44:38 +02:00
request_guard Reorganize repository. 2018-06-03 18:44:38 +02:00
request_local_state Small fixes to request-local state cache implementation. 2018-07-07 18:52:03 -07:00
session Always set 'secret_key' in session example. 2018-06-28 19:02:39 -07:00
state Reorganize repository. 2018-06-03 18:44:38 +02:00
static_files Reorganize repository. 2018-06-03 18:44:38 +02:00
stream Reorganize repository. 2018-06-03 18:44:38 +02:00
tera_templates Overhaul URI types. 2018-07-29 00:17:33 -07:00
testing Reorganize repository. 2018-06-03 18:44:38 +02:00
tls Reorganize repository. 2018-06-03 18:44:38 +02:00
todo Fix compatibility warnings and errors in examples. 2018-07-25 09:01:29 -06:00
uuid Reorganize repository. 2018-06-03 18:44:38 +02:00