require "onyx/http"
Onyx::HTTP.get "/", &.response.puts("Hello World!")
Onyx::HTTP.routes do
on "user" do
get "/:id", Endpoint::User::Get
post "/", Endpoint::User::Create
end
end
user = Onyx::SQL.query(Model::User.where(id: params.query.id)).first?
sub = Onyx::EDA.memory.subscribe(Event::MyEvent) do |e|
puts e.foo
end
The idea is to isolate top-level macros into modules, with these changes:
Onyx.get -> Onyx::HTTP.get
Onyx.query -> Onyx::SQL.query
Onyx.memory.emit -> Onyx::EDA.memory.emit # .memory is upcoming API change
This would, indeed, require to write more code, but bring better transparency to the codebase and eliminate possible clashes between methods. For example, options can both be used to define an HTTP endpoint and to configure something. The same for delete.
The idea is to isolate top-level macros into modules, with these changes:
This would, indeed, require to write more code, but bring better transparency to the codebase and eliminate possible clashes between methods. For example,
options
can both be used to define an HTTP endpoint and to configure something. The same fordelete
.