doesn't work, switching to rust

This commit is contained in:
Joe Ardent 2024-02-18 12:47:20 -08:00
parent 248574eabc
commit 31fb2000f0
4 changed files with 28 additions and 9 deletions

3
config/runtime.exs Normal file
View file

@ -0,0 +1,3 @@
import Config
config(:queen, :secret_key_base, System.fetch_env!("QUEEN_COOKIE_SECRET"))

View file

@ -1,12 +1,27 @@
defmodule Queen do defmodule QueenRouter do
import Plug.Conn use Plug.Router
def init(opts) do plug(Plug.Logger)
opts plug(:match)
plug(:dispatch)
plug(Plug.Session, store: :cookie, key: "_queen_session", signing_salt: "J6PHP10BHF23")
plug(:fetch_session)
plug(Plug.CSRFProtection)
get "/signup" do
fetch_session(conn) |> put_session(:verify, "meow") |> send_resp(200, "signup")
end end
def call(conn, _opts) do get "/success/:payment" do
:logger.debug("saying hello") conn = fetch_session(conn)
send_resp(conn, 200, "hello from queen") verify = get_session(conn, :verify)
:logger.info("got verify: #{verify}")
:logger.info("got payment receipt code #{payment}")
send_resp(conn, 200, "huzzah")
end
match _ do
send_resp(conn, 404, "you lost, kitty-cat?")
end end
end end

View file

@ -8,7 +8,7 @@ defmodule Queen.Application do
@impl true @impl true
def start(_type, _args) do def start(_type, _args) do
children = [ children = [
{Bandit, plug: Queen} {Bandit, plug: QueenRouter}
# Starts a worker by calling: Queen.Worker.start_link(arg) # Starts a worker by calling: Queen.Worker.start_link(arg)
# {Queen.Worker, arg} # {Queen.Worker, arg}
] ]

View file

@ -15,7 +15,8 @@ defmodule Queen.MixProject do
def application do def application do
[ [
# extra_applications: [:logger, :ecto_sqlite3, :ecto, :bandit, :plug] # extra_applications: [:logger, :ecto_sqlite3, :ecto, :bandit, :plug]
extra_applications: [:logger] extra_applications: [:logger],
mod: {Queen.Application, []}
] ]
end end