View Source Wobserver.Web.Router.Helper (Wobserver NG v1.14.0)

Helper methods for routers.

Link to this section Summary

Functions

Sends a JSON encoded response back to the client.

Link to this section Functions

Link to this function

send_json_resp(data, conn)

View Source
@spec send_json_resp(
  data :: atom() | String.t() | map() | list(),
  conn :: Plug.Conn.t()
) :: Plug.Conn.t()

Sends a JSON encoded response back to the client.

The https status will be 200 or 500 if the given data can not be JSON encoded.

The conn content type is set to application/json, only if the data could be encoded.