go-serv attempts to take care of common requirements for web applications while not dictating any specific Go web framework.
Repo: https://github.com/ashcrow/go-serv/
Warning: Currently in development with no official release yet.
- Built on Go's net/http library
- Framework agnostic
- Logging via logrus (https://github.com/Sirupsen/logrus/)
- Configuration file parsing via TOML (https://github.com/toml-lang/toml/)
- Flags through pflag (https://github.com/ogier/pflag)
- Command line flags which can overrule configuration file
- Simple status/health system for exposing structs
- Run HTTP and HTTPS servers with the same binary.
$ go get gopkg.in/ashcrow/go-serv.v0
$ go test -v -cover
or
$ make test
# Note that the names are the same across the BaseConfiguration
# struct, this config file, and command line flags.
BindAddress = "127.0.0.1"
BindPort = 8000
LogLevel = "info"
LogFile = "/tmp/out.log"
$ ./status-example -help
Usage of ./status-example:
--BindAddress="0.0.0.0": Bind address.
--BindHttpsPort=443: HTTPS bind port.
--BindPort=80: HTTP bind port.
--CertFile="": Cert file.
--KeyFile="": Key file.
--LogFile="": Log file.
--LogLevel="info": Log level.
--MaxHeaderBytes=1048576: Max header bytes.
--ReadTimeout=10s: Read timeout.
--WriteTimeout=10s: Write timeout.
$ ./status-example -help /path/to/conf.toml
Usage of ./status-example:
--BindAddress="127.0.0.1": Bind address.
--BindHttpsPort=8181: HTTPS bind port.
--BindPort=8000: HTTP bind port.
--CertFile="./cert.pem": Cert file.
--KeyFile="./key.pem": Key file.
--LogFile="/tmp/out.log": Log file.
--LogLevel="info": Log level.
--MaxHeaderBytes=1048576: Max header bytes.
--ReadTimeout=10s: Read timeout.
--WriteTimeout=10s: Write timeout.
Examples can be found in the examples folder
There is a Makefile provided to build the code in the examples folder.
$ make build-examples-all