https://github.com/ashcrow/go-serv
Simple web application server library built upon Go's net/http and doesn't force any framework.
https://github.com/ashcrow/go-serv
Last synced: 2 months ago
JSON representation
Simple web application server library built upon Go's net/http and doesn't force any framework.
- Host: GitHub
- URL: https://github.com/ashcrow/go-serv
- Owner: ashcrow
- License: mit
- Created: 2015-03-23T14:02:10.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-08-17T19:02:20.000Z (almost 10 years ago)
- Last Synced: 2025-02-13T18:34:56.278Z (4 months ago)
- Language: Go
- Size: 1.98 MB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-serv
[](http://godoc.org/gopkg.in/ashcrow/go-serv.v0)
[](https://travis-ci.org/ashcrow/go-serv)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.
## Features
* 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.### Installation
```bash
$ go get gopkg.in/ashcrow/go-serv.v0
```### Unittesting
```bash
$ go test -v -cover
```or
```bash
$ make test
```### Configuration File Example
```plain
# 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"
```### Default Command Line Flags
#### Application Defaults
```bash
$ ./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.
```#### Configuration File Defaults
```bash
$ ./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
Examples can be found in the [examples folder](https://github.com/ashcrow/go-serv/tree/master/examples)### Building Examples
There is a Makefile provided to build the code in the examples folder.
```bash
$ make build-examples-all
```