Packages
phasedb_server
0.0.1
A real-time time series database.
Retired package: I'll never finish it
Current section
Files
Jump to
Current section
Files
lib/phasedb/server/cowboy/http_handler.ex
defmodule PhaseDB.Server.Cowboy.HTTPHandler do
alias PhaseDB.Server.Cowboy.WebsocketHandler
@behaviour :cowboy_http
@moduledoc """
Implements enough oft he Cowboy HTTP protocol to pass it off to the websocket handler.
"""
def init({transport, :http}, req, _) when transport in ~w|tcp ssl|a do
case :cowboy_req.header("upgrade", req) do
{"websocket", _} -> {:upgrade, :protocol, WebsocketHandler}
{"WebSocket", _} -> {:upgrade, :protocol, WebsocketHandler}
_ -> {:upgrade, :protocol, __MODULE__}
end
end
end