Expand description
Controller result helpers: shortcuts for common success and error outcomes.
Okay builds 200 ServiceResult values,
while the error types build ErrorResult
values with fixed status codes. Return them directly from handlers, whose
convention is Fn(CorrelationContext) returning
Result<ServiceResult<T>, ErrorResult>.
ⓘ
async fn get_user(ctx: CorrelationContext) -> Result<ServiceResult<User>, ErrorResult> {
Ok(Okay::result(user))
}Structs§
- Authentication
Error - 401 error shortcut: builds an
ErrorResultfor failed authentication. - Authorization
Error - 403 error shortcut: builds an
ErrorResultfor denied authorization. - BadConfiguration
- 500 error shortcut: builds an
ErrorResultfor invalid server configuration. - Generic
Error - Custom-code error shortcut: builds an
ErrorResultwith a caller-chosen status. - Okay
- Success-result shortcuts: builds 200
ServiceResultvalues for handlers.