View Source Vigil.Sanitizer (vigil v0.4.4)
This module provides a callback to be used in the Plug.Conn.register_before_send/1
function.
It checks whether the connection contains an errored response from the GraphQL API.
If it does, the repsponse is sanitized into a generic HTTP response before it is returned to the user.
Link to this section Summary
Functions
Takes in a %Plug.Conn{} and if it has sensitive GraphQL errors, sanitize them before continuing with the remainder of the pipeline.
Link to this section Functions
@spec sanitize_response(conn :: Plug.Conn.t(), opts :: map()) :: Plug.Conn.t()
Takes in a %Plug.Conn{} and if it has sensitive GraphQL errors, sanitize them before continuing with the remainder of the pipeline.
If an exception occurs, this isn't worth crashing for. Return the connection unchanged, and log what happened.
As a note, the call function in the root of this project provides a similar general try/rescue, but it is bypassed when this function is used as a callback with the Plug.Conn.register_before_send/1 function. Therefore it becomes necessary to include another general try catch here to prevent exceptions from bubbling up to the remainder of the pipeline.