Skip to content

Instantly share code, notes, and snippets.

defmodule TrotSample.Router do
use Trot.Router
get "/", do: 200
get "/hello" do
"Hello Trot!!"
end
import_routes Trot.NotFound
%{"calliope": {:hex, :calliope, "0.3.0"},
"cowboy": {:hex, :cowboy, "1.0.0"},
"cowlib": {:hex, :cowlib, "1.0.1"},
"plug": {:hex, :plug, "0.12.1"},
"plug_heartbeat": {:hex, :plug_heartbeat, "0.1.0"},
"poison": {:hex, :poison, "1.4.0"},
"ranch": {:hex, :ranch, "1.0.0"},
"trot": {:git, "git://github.com/hexedpackets/trot.git", "6d4ddebfa714cc6b4b0b17f43002b3da9c68d6a2", []}}
%html
%head
%title Haml Template
%body
%h1 Haml Template
%p <%= @message %>
%html
%head
%title Haml Template
%body
%h1 Haml Template
%p <%= @message %>
%html
%head
%title Haml Template
%body
%h1 Haml Template
%p <%= @message %>
<html>
<head>
<title>EEx Template</title>
</head>
<body>
<h1>EEx Template</h1>
<p><%= @message %></p>
</body>
</html>
defmodule TrotSample.Router do
use Trot.Router
use Trot.Template
get "/", do: 200
get "/hello" do
"Hello Trot!!"
end
defp deps do
[ { :safetybox, "~> 0.1" } ]
end
defmodule SafetyboxSample do
def encrypt(password) do
Safetybox.encrypt(password)
end
def authentication(_userid, _user_name, password) do
encrypt_password = "" # DBからユーザデータを取得する処理が入る
Safetybox.is_decrypted(password, encrypt_password)
end
end
defmodule EctoModelsSample.User do
use EctoModelsSample.Web, :model
use Ecto.Model.Callbacks
before_insert :set_password_digest
schema "users" do
field :name, :string
field :email, :string
field :password_digest, :string