{"modulePath":"github.com/phcp-tech/common-library-golang","version":"v0.2.4","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package componentwithlambda\n\nPackage componentwithlambda provides HTTP server lifecycle integration for bootstrap, with AWS Lambda support.\n\nUse this package instead of httpserver/component when the service may be deployed on AWS Lambda. It reads app.runmode from env during Init() and selects the appropriate runner:\n\n  - \"aws\\_lambda\" → httpserver/lambda.NewHttpServer()\n  - anything else → httpserver.NewHttpServer() (plain HTTP/HTTPS)\n\nImporting this package pulls in the AWS Lambda SDK. Services that never run on Lambda should use httpserver/component to keep their binary free of unnecessary dependencies.\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 with Lambda support.\n\nhandler is a lazy provider called during Init() to obtain the http.Handler (typically \\*gin.Engine). The runner is selected at Init() time based on the app.runmode env key.\n\ncfg is optional and configures the VM/plain-HTTP runner branch only - pass at most one; extra values beyond the first are ignored. Its Port field is always overwritten from the http.server.port env key regardless of what it's set to, so it only needs to carry the fields httpserver.Config otherwise defaults (WriteTimeout, ReadTimeout, TLS files, ...). The Lambda runner takes no config at all, so cfg has no effect when app.runmode is \"aws\\_lambda\". Omitting cfg entirely 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 VM-mode write timeout without losing Lambda support - Lambda mode is unaffected by this option:\n\n\tAdd(httpComp.Component(func() http.Handler { return router },\n\t    httpserver.Config{WriteTimeout: httpserver.NoWriteTimeout}))\n\n","path":"github.com/phcp-tech/common-library-golang/httpserver/componentwithlambda","name":"componentwithlambda","synopsis":"Package componentwithlambda provides HTTP server lifecycle integration for bootstrap, with AWS Lambda support.","isRedistributable":true}
