Documentation
¶
Overview ¶
Package rest is the HTTP presentation layer over the service package. No business logic lives here; each handler calls a service method and maps the result to JSON or an HTTP error.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps a Service and exposes its methods over HTTP.
func New ¶
New creates a Server. svc may have a nil OANDA client for backtest-only use; endpoints that require OANDA will respond 503 in that case.
func (*Server) Handler ¶
Handler returns the http.Handler (mux) with all routes wired up. Exposed so tests can call ServeHTTP directly without binding a port.
func (*Server) WithConfigsDir ¶ added in v0.2.3
WithConfigsDir sets the directory from which backtest config files are listed. Call before Serve. Defaults to /srv/trading/backtests/configs.
func (*Server) WithMCPHandler ¶ added in v0.2.3
WithMCPHandler mounts an MCP HTTP handler at POST /mcp so that the MCP server is reachable on the same port as the REST API when running trader serve. Pass the result of mcp.Server.HTTPHandler().
func (*Server) WithReportsDir ¶
WithReportsDir sets the directory from which backtest JSON reports are served. Call before Serve. Defaults to /srv/trading/backtests/reports.
func (*Server) WithStatic ¶
WithStatic sets the fs.FS from which the UI static assets are served. Call before Serve. The FS should be rooted at the dist/ directory (i.e. "index.html" should open directly, not "dist/index.html").