pub fn dev_routes<S: Clone + Send + Sync + 'static>(
previews: &'static [Preview],
) -> Router<S>Expand description
Development pages for email, served by ocre dev only, like Rails’ /rails/mailers and Action Mailbox’s conductor.
GET /ocre/dev/mailers: thepreviewsand the last 20 emails sent withMAIL_ADAPTER = "log"by this Worker instance (requests, jobs anddeliver_lateralike), newest first.GET /ocre/dev/mailers/preview/<name>: one preview, rendered now.GET /ocre/dev/mailers/sent/<id>: one captured email.GET /ocre/dev/mailers/sent.json: the captured emails as JSON ([{"id": 1, "from": "...", "email": {...}}], oldest first), so an end-to-end test can read a magic link without parsing logs.GET /ocre/dev/mailbox: a form that delivers a test email to the app’s mailbox (ocre g mailbox) through wrangler’s local/cdn-cgi/local/emailendpoint.
The pages exist in debug builds only (ocre dev builds with --dev);
in release builds (ocre deploy) this returns an empty router, so they
are 404s in production. ocre g mailer and ocre g mailbox merge it
into routes() in src/lib.rs. It uses no billed resource: previews
render in the request, captured emails live in the Worker’s memory.
§Examples
use axum::Router;
use ocre::{Ctx, mail::Preview};
static PREVIEWS: &[Preview] = &[];
fn routes() -> Router<Ctx> {
Router::new()
// ocre:routes
.merge(ocre::mail::dev_routes(PREVIEWS))
}