NewWithManager builds a Server around an already-constructed SessionManager. Useful when the runtime is owned by another component (e.g. the TUI) and only needs to be exposed over HTTP.
(sm *SessionManager, authToken string)
| 41 | // Useful when the runtime is owned by another component (e.g. the TUI) and |
| 42 | // only needs to be exposed over HTTP. |
| 43 | func NewWithManager(sm *SessionManager, authToken string) *Server { |
| 44 | e := echo.New() |
| 45 | e.Use(echolog.RedactedRequestLogger()) |
| 46 | e.Use(echo.WrapMiddleware(upstream.Handler)) |
| 47 | |
| 48 | // Add bearer token middleware if token is configured |
| 49 | if authToken != "" { |
| 50 | e.Use(BearerTokenMiddleware(authToken)) |
| 51 | } |
| 52 | |
| 53 | s := &Server{e: e, sm: sm, authToken: authToken} |
| 54 | s.registerRoutes() |
| 55 | return s |
| 56 | } |
| 57 | |
| 58 | func (s *Server) registerRoutes() { |
| 59 | // Health and readiness endpoints (not under /api) |