GoodAnalytics.Core.Links.QRController (GoodAnalytics v0.1.1)

Copy Markdown View Source

Phoenix controller that serves QR code images for short links.

Trust boundary

All user-supplied query parameters (format, size, fg, bg, ec) are validated by validate_params/1 before use. The binary written to the response is produced entirely by the QR-code library and never contains user-supplied data. The content_type passed to put_resp_content_type/3 is returned by the private content_type/1 function, which maps the validated :svg / :png atom to one of exactly two hard-coded MIME strings — it is not derived from request input.

Summary

Functions

Renders a QR code image for the short link identified by key.

Functions

show(conn, params)

@spec show(Plug.Conn.t(), map()) :: Plug.Conn.t()

Renders a QR code image for the short link identified by key.

Accepts optional query parameters: format (svg|png), size (1..50), fg / bg (6-char hex), ec (low|medium|quartile|high).

Responds with the appropriate image content type and a 24-hour cache-control header on success, or a 4xx/5xx text response on error.