Plug 套件還提供了 Plug.Router,裡面有現成的解析路徑 DSL 供我們使用,
讓我們定義一個 Router 並將第一個 Plug 改成它
建立一個新的檔案 lib/my_router.ex
defmodule MyRouter do
  use Plug.Router
  
  plug :match
  plug :dispatch
  
  get "/hello" do
    send_resp(conn, 200, "world")
  end
  
  match _ do
    send_resp(conn, 404, "not found")
  end
end
在這個 MyRouter plug 裡面使用 use Plug.Router 後,
提供了我們 plug :match 與 plug :dispatch 這兩個 plug
與符合 http 方法的函式 (get, post, put, patch, delete)
也可以從路徑裡面提取變數
get "hello/:name" do
  send_resp(conn, 200, "hello #{name}"
end