Sucrose v0.1.3 Sucrose.Common

This is the common module to be shared / used amongst the middleware policies.

Link to this section Summary

Functions

This is the default error handler to put when we want to deny something.

Handle the responses, return, warn, or error based upon the response.

Link to this section Functions

Link to this function

handle_censor(check, censor)

Link to this function

handle_error(check, message \\ "Unauthorized")

This is the default error handler to put when we want to deny something.

Link to this function

handle_response(response, check)

Handle the responses, return, warn, or error based upon the response.

  1. true - return the normal response
  2. {:ok, _} -> return the normal response
  3. {:censor, val} -> censor the value and put the response
  4. false - return null / log warn message
  5. :error - return nil / log warn message
  6. {:error, msg} - return null / log warn message and return the msg on the payload