Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commitc6c8124

Browse files
committed
refactor(editor-js): test json api, wip
1 parent916ea66 commitc6c8124

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
defmoduleGroupherServerWeb.Controller.OGdo
2+
useGroupherServerWeb,:controller
3+
# alias Todos.Todo
4+
# plug(:action)
5+
6+
defindex(conn,_params)do
7+
# todos = Repo.all(Todo)
8+
json(conn,%{hello:"world"})
9+
# render(conn, %{hello: "world"})
10+
# text(conn, "BusiApi!")
11+
end
12+
end

‎lib/groupher_server_web/router.ex‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ defmodule GroupherServerWeb.Router do
1010
plug(GroupherServerWeb.Context)
1111
end
1212

13+
aliasGroupherServerWeb.Controller
14+
15+
scope"/api"do
16+
pipe_through(:api)
17+
18+
# get "/og-info", TodoController, only: [:index]
19+
# resources("/og-info", OG, only: [:index])
20+
get("/og-info",Controller.OG,:index)
21+
end
22+
1323
scope"/graphiql"do
1424
pipe_through(:api)
1525

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
defmoduleGroupherServerWeb.Test.Controller.OGdo
2+
@moduledoc"""
3+
test open-graph fether
4+
"""
5+
useGroupherServer.TestTools
6+
7+
@tag:wip2
8+
test"basic should work"do
9+
conn=build_conn()
10+
11+
res=get(conn,"/api/og-info")
12+
# res = conn(:get, "/api/og-info")
13+
# |> put_private(:plug_skip_csrf_protection, true)
14+
# |> GroupherServerWeb.Endpoint.call([])
15+
16+
IO.inspect(json_response(res,200),label:"res")
17+
# IO.inspect(text_response(res, 200), label: "res")
18+
# conn = get conn, todo_path(conn, :index)
19+
20+
# IO.inspect json_response(conn, 200), label: "lulu"
21+
22+
# assert json_response(conn, 200) == %{
23+
# "todos" => [%{
24+
# "title" => todo.title,
25+
# "description" => todo.description,
26+
# "inserted_at" => Ecto.DateTime.to_iso8601(todo.inserted_at),
27+
# "updated_at" => Ecto.DateTime.to_iso8601(todo.updated_at)
28+
# }]
29+
# }
30+
end
31+
end

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp