OxL Справочник OxL
РусскийEnglish

data Response

What a middleware returns: the outcome of the rest of the chain (next(ctx)) or an answer of its own. A response is either the pass-through of the handler's result (the typed value stays with the handler: a middleware cannot rewrite it) or a NetError (Response.refuse(e), short-circuit).

Example:

oxl✓ проверяется в CI
attr Guarded {}

impl Middleware for Guarded {
  fn around(ctx: &var Ctx, next: Next) -> Response net, io, time, db {
    if !ctx.caller.isUser(none) { return Response.refuse(AccessDenied{}) }
    next(ctx)
  }
}
pub(api) data Response

С версии. 1.0.0-beta

Поля

pub(api) error: NetError? = none

The error the call ends with; none when the handler's own result stands.

pub(api) passed: bool = false

next ran (and the handler answered): false for a response made by refuse / Response.of.

Методы

refuse(e: NetError) -> Response
A short-circuit answer
failed() -> bool
true when the call ended with a NetError (a refusal, or an error of the handler itself, that next reported).

Определено в: std/core/rpc.oxl:442

См. также