Skip to end of banner
Go to start of banner

Response Handler Configuration

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 24 Next »

Both Generic OAuth2.0 and Callout Authenticator API policies contain a Response Handler field in which you can configure an expression to determine how the response is being interpreted. You can use anything in the response received from the callout to your URL.

Inside of this Response Handler field, you have two expression objects available:

  • The "response" object which contains the response from the callout to your URL.
  • The "Result" object, which contains functions to control how you want the response to be handled.

You can modify the Response Handler expression according to your own response handling logic, using the functions inside the Result object defined in the following table:

Result FunctionsDescription
{
    ok: entity => { variant: 'OK', value: entity }


    ignore: () => { variant: 'IGNORE' },


    err: reason => { variant: 'ERROR', reason: reason }
}
You call the OK function when you want the response to be accepted.
You call the Ignore function when you want the response to be ignored.
You call Error function when you want the response to result in an error.

Default Response Handler expression:

match response

{
       { statusCode: 200..<300, entity } => Result.ok(entity),
       { statusCode: 401|404 } => Result.ignore(),
       { status } => Result.err(status),
       _ => Result.err('Invalid response: ' + response.toString())

}


  • No labels