AudioProxy.Plugs.Action (audio_proxy v0.4.0)

Copy Markdown View Source

Picks the action at the end of the signed chain: render, or info.

Dispatch cannot happen in the router. /{sig}/info/{source} and /{sig}/f:mp3/{source} are the same route — a signature, then a rest — and which endpoint was asked for is only knowable once the signature has been verified and the rest split into its options half. That is AudioProxy.Plugs.ParseOptions' job, and it says so by assigning :action. This plug reads it, and nothing else does.

Keeping it a separate plug rather than a clause inside either action is what keeps both actions ignorant of the other. Each has its own options, passed through under its own key, so a test mounting a stand-in binary names which one it is standing in for:

plug AudioProxy.Plugs.Action, render: [executable: "…/fake_ffmpeg.sh"]
plug AudioProxy.Plugs.Action, info: [executable: "…/fake_ffprobe.sh"]

Summary

Types

Plug options: per-action option lists, each forwarded verbatim to that action's init/1.

Types

opts()

@type opts() :: [render: keyword(), info: keyword()]

Plug options: per-action option lists, each forwarded verbatim to that action's init/1.