Mooncore.Endpoint.Http (mooncore v0.2.4)

Copy Markdown

HTTP transport adapter.

Converts an HTTP request (Plug.Conn) into an action call and returns the result. Users call this from their router.

Usage in your router

match "/run" do
  Mooncore.Endpoint.Http.handle(conn)
end

Request Map

The entire parsed request body (conn.params) becomes req[:params]. For a request like:

POST /run {"action": "task.create", "title": "Hello"}

The handler receives:

%{
  auth: %{...} | nil,
  params: %{"action" => "task.create", "title" => "Hello"}
}

User data sits alongside the "action" key — there is no extra nesting.

Summary

Functions

Handle an HTTP request: extract action from params, build request map, execute action through the pipeline, return JSON response via conn.

Build request map from conn and execute the action through the pipeline. Returns raw action result (not formatted, not encoded). Use this if you want to control the HTTP response yourself.

Functions

handle(conn)

Handle an HTTP request: extract action from params, build request map, execute action through the pipeline, return JSON response via conn.

receive_action(conn)

Build request map from conn and execute the action through the pipeline. Returns raw action result (not formatted, not encoded). Use this if you want to control the HTTP response yourself.