pub struct DevtoolsServiceProvider { /* private fields */ }Expand description
Turns the developer tools on in an application that registers it.
They run only in a build with debug assertions, with APP_ENV=local, and unless
DEVTOOLS_ENABLED=false: there the provider records every request, console command, queued
job and scheduled task into storage/devtools, which belongs in the application’s
.gitignore. Everywhere else, in its tests too, the provider adds nothing. A build without
debug assertions, as Cargo’s release profile is by default, has nothing of the developer tools
compiled in but DevtoolsConfig, so that an application’s configuration of it builds either
way. What decides is debug-assertions, not the profile’s name.
Who sees them: a browser on the application’s own machine, unless DEVTOOLS_LOCAL=false, and
anyone else who entered DEVTOOLS_KEY; of those, only whom a DevtoolsGate lets in, if the
application sets one. Everyone else gets neither the toolbar nor its routes, which answer 404.
use laravel_rust_devtools::DevtoolsServiceProvider;
laravel::Application::configure().with_providers(|providers| {
providers.add(DevtoolsServiceProvider::new());
});Implementations§
Source§impl DevtoolsServiceProvider
impl DevtoolsServiceProvider
Sourcepub fn new() -> Self
pub fn new() -> Self
The provider, letting in whom the rules above let in.
let provider = laravel_rust_devtools::DevtoolsServiceProvider::new();Sourcepub fn with_gate(self, gate: impl DevtoolsGate) -> Self
pub fn with_gate(self, gate: impl DevtoolsGate) -> Self
Let in only whom gate allows, of those the rules above let in. A build without debug
assertions has no developer tools, and drops the gate.
use laravel::http::Request;
use laravel_rust_devtools::{DevtoolsGate, DevtoolsServiceProvider};
struct Nobody;
impl DevtoolsGate for Nobody {
async fn allows(&self, _request: &Request) -> laravel::Result<bool> {
Ok(false)
}
}
let provider = DevtoolsServiceProvider::new().with_gate(Nobody);Sourcepub fn with_crates<I>(self, crates: I) -> Self
pub fn with_crates<I>(self, crates: I) -> Self
Also record the spans and lines of these downloaded crates, such as packages the
application installed from crates.io. Without them, the developer tools record the
framework and the application’s own crates, and the packages it builds from a path. Names
may be written with - or _.
A line belongs to a crate by its target’s first part, which is the crate’s name unless the crate sets targets of its own: name those instead.
A named crate’s lines are recorded by the same rules as the application’s: a field whose
name suggests a secret, such as password, token or session_id, as [masked], and
everything else as it was written, the line’s message and every field with an ordinary
name. Name only crates whose lines don’t carry values that everyone who can read the traces
may not see. Libraries whose lines carry values stay out even when named: sqlx and every
crate named sqlx_*, lettre and aws_smithy_runtime. A build without debug assertions has
no developer tools, and drops the names.
use laravel_rust_devtools::DevtoolsServiceProvider;
let provider = DevtoolsServiceProvider::new().with_crates(["laravel-rust-permissions"]);