Skip to main content

dev_routes

Function dev_routes 

Source
pub fn dev_routes<S: Clone + Send + Sync + 'static>() -> Router<S>
Expand description

Development endpoint listing recent broadcasts, served by ocre dev only, for tests (Rails’ assert_broadcasts).

GET /ocre/dev/realtime/sent.json answers the last 50 messages broadcast sent from this Worker instance (requests and jobs alike), oldest first: [{"id": 1, "channel": "posts", "message": "<tr ...>"}]. An end-to-end test triggers a change, then checks what went out without opening a WebSocket (ocre::testing::Client reads it). Only successful broadcasts are listed.

Debug builds only (ocre dev); release builds (ocre deploy) get an empty router, so it is a 404 in production. ocre g scaffold ... --realtime merges it into the routes of src/realtime.rs. It uses no billed resource: the list lives in the Worker’s memory.

§Examples

use axum::{Router, routing::get};
use ocre::Ctx;

fn routes() -> Router<Ctx> {
    Router::new().route("/realtime/{channel}", get(connect)).merge(ocre::realtime::dev_routes())
}