Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/borislavv/go-httpserver
HTTP SERVER: Wrapper over fasthttp
https://github.com/borislavv/go-httpserver
fasthttp golang library wrapper
Last synced: 27 days ago
JSON representation
HTTP SERVER: Wrapper over fasthttp
- Host: GitHub
- URL: https://github.com/borislavv/go-httpserver
- Owner: Borislavv
- License: apache-2.0
- Created: 2024-09-30T13:31:19.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-11-27T15:08:13.000Z (about 1 month ago)
- Last Synced: 2024-12-07T03:08:52.278Z (27 days ago)
- Topics: fasthttp, golang, library, wrapper
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## HTTP SERVER: Wrapper over fasthttp.
### Usage:
ctx, cancel := context.WithCancel(ctx)
defer cancel()cfg, err := sharedconfig.Load()
if err != nil {
return nil, err
}lgr, lgrCancel, err := logger.NewLogrus(output)
if err != nil {
return nil, err
}
defer lgrCancel()sharedserver.
NewHTTP(
ctx,
lgr,
cfg,
[]controller.HttpController{
controller.NewK8SProbe(ctx, logger, liveness),
},
[]middleware.HttpMiddleware{
/** exec 1st. */ middleware.NewInitCtxMiddleware(ctx, config),
/** exec 2nd. */ middleware.NewApplicationJsonMiddleware(),
},
).
ListenAndServe()### ENV:
type Config struct {
// HttpServerName is a name of the shared server.
HttpServerName string `envconfig:"HTTP_SERVER_NAME" default:"http_server"`
// HttpServerPort is a port for shared server (endpoints like a /probe for k8s).
HttpServerPort string `envconfig:"HTTP_SERVER_PORT" default:":8000"`
// HttpServerShutDownTimeout is a duration value before the server will be closed forcefully.
HttpServerShutDownTimeout time.Duration `envconfig:"HTTP_SERVER_SHUTDOWN_TIMEOUT" default:"5s"`
// HttpServerRequestTimeout is a timeout value for close request forcefully.
HttpServerRequestTimeout time.Duration `envconfig:"HTTP_SERVER_REQUEST_TIMEOUT" default:"1m"`
}