OxL Reference

method Middleware.around

Wraps every call of the rpc the attribute is written on: runs code before and after next(ctx), or refuses the call with Response.refuse(e) without calling next.

Example:

oxl✓ checked in CI
attr Timed {}

impl Middleware for Timed {
  fn around(ctx: &var Ctx, next: Next) -> Response net, io, time, db {
    let t0 = Instant.now()
    let r = next(ctx)
    print("took {t0.elapsed().millis()} ms")
    r
  }
}
fn around(ctx: &var Ctx, next: Next) -> Response  net, io, time, db

Since. 1.0.0-beta

Parameters

NameType
ctx&var Ctx
nextNext

Returns

Response

Effects

net, io, time, db

Defined in: std/core/rpc.oxl:542

See also