rest

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2026 License: BSD-2-Clause Imports: 18 Imported by: 0

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

func New(svc *service.Service, addr string) *Server

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

func (s *Server) Handler() http.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) Serve

func (s *Server) Serve(ctx context.Context) error

Serve starts listening on s.addr and blocks until ctx is cancelled.

func (*Server) WithConfigsDir added in v0.2.3

func (s *Server) WithConfigsDir(dir string)

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

func (s *Server) WithMCPHandler(h http.Handler)

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

func (s *Server) WithReportsDir(dir string)

WithReportsDir sets the directory from which backtest JSON reports are served. Call before Serve. Defaults to /srv/trading/backtests/reports.

func (*Server) WithStatic

func (s *Server) WithStatic(fsys fs.FS)

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").

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL