starting to set up routing in csys app
This commit is contained in:
parent
8951df4282
commit
b24c82fe57
6 changed files with 47 additions and 8 deletions
|
|
@ -11,11 +11,13 @@ defmodule Scopes.CSys.Application do
|
|||
def start(type, args) do
|
||||
IO.puts("Hello CSys")
|
||||
Logger.info(Util.show [type, args])
|
||||
# input_neurons = Environ.create_input
|
||||
IO.inspect Scopes.CSys.Server.Endpoint.child_spec(input: %{[:csys, :s01] => "dummy"})
|
||||
children = [
|
||||
#Scopes.Web.Server.Endpoint
|
||||
Scopes.CSys.Server.Endpoint
|
||||
#Scopes.CSys.Server.Endpoint
|
||||
{Scopes.CSys.Server.Endpoint, input: %{[:csys, :s01] => "dummy"}}
|
||||
]
|
||||
opts = [strategy: :one_for_one, name: Scopes.Supervisor]
|
||||
opts = [strategy: :one_for_one, name: Scopes.CSys.Supervisor]
|
||||
Supervisor.start_link(children, opts)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
defmodule Scopes.CSys.Server.Endpoint do
|
||||
use Phoenix.Endpoint, otp_app: :scopes_csys
|
||||
|
||||
def init(arg) do
|
||||
IO.inspect(arg)
|
||||
IO.inspect(Process.get())
|
||||
:ignore
|
||||
end
|
||||
|
||||
plug Plug.Static,
|
||||
at: "/",
|
||||
from: :scopes_csys,
|
||||
|
|
@ -15,5 +21,6 @@ defmodule Scopes.CSys.Server.Endpoint do
|
|||
pass: ["*/*"],
|
||||
json_decoder: Phoenix.json_library()
|
||||
|
||||
plug Scopes.Web.Server.Router
|
||||
plug Scopes.CSys.Server.Router
|
||||
#input_neurons: @input
|
||||
end
|
||||
|
|
|
|||
23
apps/csys/lib/server/router.ex
Normal file
23
apps/csys/lib/server/router.ex
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
defmodule Scopes.CSys.Server.Router do
|
||||
use Scopes.Web.Server, :router
|
||||
|
||||
pipeline :api do
|
||||
plug :accepts, ["json"]
|
||||
end
|
||||
|
||||
scope "/api", Scopes.CSys.Server do
|
||||
pipe_through :api
|
||||
match :*, "/csys/:action/s01/:item", Controller, :index
|
||||
end
|
||||
end
|
||||
|
||||
defmodule Scopes.CSys.Server.Controller do
|
||||
use Scopes.Web.Server, :controller
|
||||
|
||||
def index(conn, params) do
|
||||
# input_neuron = Environ.get_input(:csys, :s01)
|
||||
json(conn, params)
|
||||
#render(conn, :index, message: "Hello CSys")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -19,8 +19,8 @@ defmodule Scopes.Web.Server.ErrorJSON do
|
|||
# By default, Phoenix returns the status message from
|
||||
# the template name. For example, "404.json" becomes
|
||||
# "Not Found".
|
||||
def render(template, assigns) do
|
||||
message = assigns.reason.message
|
||||
def render(template, resp) do
|
||||
message = resp.reason.message
|
||||
Logger.warning(Util.show [message])
|
||||
%{errors: %{detail: Phoenix.Controller.status_message_from_template(template)}}
|
||||
end
|
||||
|
|
|
|||
7
mix.exs
7
mix.exs
|
|
@ -17,8 +17,11 @@ defmodule Scopes.MixProject do
|
|||
# Run "mix help compile.app" to learn about applications.
|
||||
def application do
|
||||
[
|
||||
#mod: {Scopes.Application, []},
|
||||
extra_applications: [:logger, :runtime_tools]
|
||||
mod: {Scopes.Application, []},
|
||||
extra_applications: [:logger, :runtime_tools],
|
||||
env: [
|
||||
serve_endpoints: false
|
||||
]
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,12 @@ defmodule Scopes.CoreActorTest do
|
|||
|
||||
describe "actors:" do
|
||||
test "basic-life-cycle" do
|
||||
Registry.start_link(keys: :unique, name: Actors)
|
||||
this = self()
|
||||
ac = Actor.create(fn msg -> send(this, msg) end)
|
||||
# Actor.register(Actors, :demo, [])
|
||||
# [{pid, _value}] = Registry.lookup(Actors, :demo)
|
||||
# assert pid == ac
|
||||
Actor.send(ac, "Hello Actor!")
|
||||
assert_receive "Hello Actor!"
|
||||
Actor.become(ac, fn _msg -> send(this, "Goodbye") end)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue