MCPcopy Create free account
hub / github.com/compozy/agh / New

Function New

internal/api/httpapi/server.go:468–490  ·  view source on GitHub ↗

New constructs an HTTP API server.

(opts ...Option)

Source from the content-addressed store, hash-verified

466
467// New constructs an HTTP API server.
468func New(opts ...Option) (*Server, error) {
469 homePaths, err := aghconfig.ResolveHomePaths()
470 if err != nil {
471 return nil, fmt.Errorf("httpapi: resolve home paths: %w", err)
472 }
473
474 server := newDefaultServer(homePaths)
475 applyOptions(server, opts)
476 if err := server.finalize(); err != nil {
477 return nil, err
478 }
479
480 staticSource, err := newStaticFS()
481 if err != nil {
482 return nil, fmt.Errorf("httpapi: load frontend bundle: %w", err)
483 }
484 server.ensureEngine()
485 server.staticSource = staticSource.source
486 server.handlers = newHandlers(server.handlerConfig(staticSource.fs))
487 RegisterRoutes(server.engine, server.handlers)
488
489 return server, nil
490}
491
492func newDefaultServer(homePaths aghconfig.HomePaths) *Server {
493 return &Server{

Calls 8

newStaticFSFunction · 0.85
newDefaultServerFunction · 0.70
applyOptionsFunction · 0.70
newHandlersFunction · 0.70
RegisterRoutesFunction · 0.70
finalizeMethod · 0.45
ensureEngineMethod · 0.45
handlerConfigMethod · 0.45