Fakultas Ilmu Komputer UI

Commit 55b4be99 authored by Muhammad Rafif Elfazri's avatar Muhammad Rafif Elfazri
Browse files

add option to get user information byusername

parent eb4727ae
......@@ -28,6 +28,11 @@ defmodule DiskuyWeb.UserController do
render(conn, "show.json", user: user)
end
def show_by_username(conn, %{"name" => name}) do
user = Account.get_by_username!(name)
render(conn, "show.json", user: user)
end
def update(conn, %{"id" => id, "user" => user_params}) do
user = Account.get_user!(id)
......
......@@ -40,6 +40,7 @@ defmodule DiskuyWeb.Router do
pipe_through :api
get "/users", UserController, :index
get "/users/:id", UserController, :show
get "/users/name/:name", UserController, :show_by_username
resources "/topics", TopicController, except: [:new, :edit, :create, :update, :delete]
options "/topics", TopicController, :options
options "/topics/:id", TopicController, :options
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment