Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mtojek/localserver
Go HTTP/HTTPS server, useful in unit tests.
https://github.com/mtojek/localserver
Last synced: 27 days ago
JSON representation
Go HTTP/HTTPS server, useful in unit tests.
- Host: GitHub
- URL: https://github.com/mtojek/localserver
- Owner: mtojek
- License: apache-2.0
- Created: 2015-09-21T14:59:30.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-24T18:42:32.000Z (over 9 years ago)
- Last Synced: 2024-10-27T05:47:40.026Z (2 months ago)
- Language: Go
- Homepage:
- Size: 152 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# localserver
[![Build Status](https://travis-ci.org/mtojek/localserver.svg?branch=master)](https://travis-ci.org/mtojek/localserver)Go HTTP/HTTPS server, useful in unit tests
Status: **Done**
Keywords: Go HTTP server, Go HTTPS server, TLS, unit tests
Simple implementation of HTTP/HTTPS server useful in unit tests. It supports starting nad stopping the listener. User can provide its own server certificates.
## Features
* HTTP and HTTPS support
* x509 certificates support
* Really simple usage## Sample usage
~~~
func TestStartHTTPSServer(t *testing.T) {
assert := assert.New(t)// given
hostPort := "127.0.0.1:9000"
scheme := "https"
sut := NewLocalServer(hostPort, scheme)// when
sut.StartTLS("resources/certs/server_ca.pem", "resources/certs/server_ca.key")
isRunning := checkIfLocalServerIsRunning(scheme + "://" + hostPort)// then
sut.Stop()assert.True(isRunning, "Server should be available now")
}
~~~