Skip to content

Instantly share code, notes, and snippets.

@rayrayzayzay
Last active April 15, 2023 03:32
Show Gist options
  • Save rayrayzayzay/83da6bb3266301e0f3e3541f98e253ae to your computer and use it in GitHub Desktop.
Save rayrayzayzay/83da6bb3266301e0f3e3541f98e253ae to your computer and use it in GitHub Desktop.
defmodule Felt.Channels.MapChannel do
use ChannelHandler.Router
def join(_topic, _payload, socket) do
{:ok, socket}
end
router do
plug &Plugs.ensure_authenticated/4
scope "elements:" do
plug &Plugs.ensure_map_editable/4
plug &Plugs.check_feature_flag/4, :element_imports
event "create", Felt.Channels.ElementHandler, :create
event "update", Felt.Channels.ElementHandler, :update
event "delete", Felt.Channels.ElementHandler, :delete
end
delegate "layer:", Felt.Channels.LayerHandler
delegate "sync:", Felt.Channels.SyncHandler
# Catch all clause
handle "", fn _payload, _context, socket ->
{:reply, {:error, "Unknown message format"}, socket}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment