View Source Membrane.WebRTC.WhipServer.Router (Membrane WebRTC plugin v0.24.0)

WHIP router pluggable to a plug pipeline.

Accepts the same options as Membrane.WebRTC.WhipServer.

Example

defmodule Router do
  use Plug.Router

  plug(Plug.Logger)
  plug(Plug.Static, at: "/static", from: "assets")
  plug(:match)
  plug(:dispatch)

  forward(
    "/whip",
    to: Membrane.WebRTC.WhipServer.Router,
    handle_new_client: &__MODULE__.handle_new_client/1
  )

  def handle_new_client(token) do
    validate_token!(token)
    signaling = Membrane.WebRTC.Signaling.new()
    # pass the signaling to a pipeline
    {:ok, signaling}
  end
end

Bandit.start_link(plug: Router, ip: any)