DeviceStructure
This module is designed to facilitate the Device structure (Plug.Conn.assign) and easy connection to other projects.
Installation
The module can be installed by adding ds to your list of dependencies in mix.exs with git url:
def deps do
[
{:ds, "~> 1.0"}
]
endRun mix task for download UAInspector databases:
$ mix ua_inspector.downloadUsage
Create new pipeline in your Router file:
defmodule ExampleWeb.Router do
use ExampleWeb.Router
pipeline :device_detectable do
plug DSPlug
end
# Add pipeline to scope
scope "/", ExampleWeb do
pipe_through [:browser, :device_detectable]
get "/", ExampleController, :index
end
endNow you can access it from your controller.
def ExampleController do
use ExampleWeb, :controller
def index(conn, _params) do
IO.inspect(conn.assigns[:device_info])
text(conn, "OK")
end
endDependencies used in library
defp deps do
[
{:plug_cowboy, "~> 2.0"},
{:ua_inspector, "~> 0.20"},
{:jason, "~> 1.1"}
]
end- https://github.com/elixir-plug/plug_cowboy
- https://github.com/elixytics/ua_inspector
- https://github.com/michalmuskala/jason
License
This project is licensed under the terms of the MIT license.