mirror of https://github.com/fafhrd91/actix-web
docs(actix-router): document Resource trait (#3935)
Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
This commit is contained in:
parent
36dadc5351
commit
f120479030
|
|
@ -1,11 +1,16 @@
|
||||||
use crate::Path;
|
use crate::Path;
|
||||||
|
|
||||||
// TODO: this trait is necessary, document it
|
/// Abstraction over types that can provide a mutable [`Path`] for routing.
|
||||||
// see impl Resource for ServiceRequest
|
///
|
||||||
|
/// This trait is used by the router to extract the request path in a uniform way across different
|
||||||
|
/// request types (e.g., Actix Web's `ServiceRequest`). Implementors return a mutable [`Path`]
|
||||||
|
/// wrapper so routing can read and potentially normalize/parse the path without requiring the
|
||||||
|
/// original request type.
|
||||||
pub trait Resource {
|
pub trait Resource {
|
||||||
/// Type of resource's path returned in `resource_path`.
|
/// Type of resource's path returned in `resource_path`.
|
||||||
type Path: ResourcePath;
|
type Path: ResourcePath;
|
||||||
|
|
||||||
|
/// Returns a mutable reference to the path wrapper used by the router.
|
||||||
fn resource_path(&mut self) -> &mut Path<Self::Path>;
|
fn resource_path(&mut self) -> &mut Path<Self::Path>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue