{"modulePath":"github.com/phcp-tech/common-library-golang","version":"v0.2.7","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package component\n\nPackage component provides HTTP server lifecycle integration for bootstrap.\n\n## Functions\n\n```go\nfunc Component(handler func() http.Handler, cfg ...httpserver.Config) bootstrap.IComponent\n```\nComponent wraps the HTTP server as a bootstrap.IComponent.\n\nhandler is a lazy provider called during Init() to obtain the http.Handler (typically \\*gin.Engine). Passing a function rather than the handler directly defers evaluation until Init() time, at which point the Gin component has already been initialised.\n\ncfg is optional; pass at most one - extra values beyond the first are ignored. It supplies every httpserver.Config field except Port, which is always overwritten from the http.server.port env key regardless of what cfg.Port is set to. Omitting cfg reproduces this function's previous behavior (a Config with only Port set).\n\nTypical usage with a bridge variable in main:\n\n\tvar router *gin.Engine\n\tAdd(ginComp.Component(func(r *gin.Engine) {\n\t    router = r\n\t    adapter.Mount(r)\n\t})).\n\tAdd(httpComp.Component(func() http.Handler { return router }))\n\nA service with a long-lived SSE/streaming endpoint can raise (or disable) the write timeout without giving up bootstrap's lifecycle management (see [ComponentWithRunner](#ComponentWithRunner) for the previous, more verbose way to do this):\n\n\tAdd(httpComp.Component(func() http.Handler { return router },\n\t    httpserver.Config{WriteTimeout: httpserver.NoWriteTimeout}))\n\n```go\nfunc ComponentWithRunner(handler func() http.Handler, factory func() httpserver.IRunner) bootstrap.IComponent\n```\nComponentWithRunner wraps the HTTP server as a bootstrap.IComponent using a custom runner factory. Use this when the caller needs to control how the IRunner is created — for example, to inject a Lambda runner.\n\nPrefer [Component](#Component) for plain HTTP/HTTPS deployments.\n\n","path":"github.com/phcp-tech/common-library-golang/httpserver/component","name":"component","synopsis":"Package component provides HTTP server lifecycle integration for bootstrap.","isRedistributable":true}
