Commit bde15188 authored by Jonas Jasas's avatar Jonas Jasas

GoDoc

parent 784930c5
Pipeline #165823736 passed with stages
in 4 minutes
......@@ -14,7 +14,9 @@ HTTP client to client (web browser to web browser) communication
[Download executable](https://gitlab.com/jonas.jasas/httprelay/-/releases) (Linux, Mac, Windows)
### Docker
- Latest image: `jonasjasas/httprelay:latest`
Docker image is built without additional layers. Final image size is less than 3Mb.
- Latest image: `jonasjasas/httprelay`
- [Image list](https://hub.docker.com/r/jonasjasas/httprelay)
- Run: `docker run -p 8080:8080 jonasjasas/httprelay`
......
......@@ -9,8 +9,10 @@ import (
"time"
)
// Server version string
var Version string
// Server instance struct
type Server struct {
net.Listener
stopChan chan struct{}
......@@ -23,6 +25,7 @@ type Waiter interface {
Wait() <-chan struct{}
}
// NewServer creates new `HTTP Relay` server instance and returns it.
func NewServer(listener net.Listener) (server *Server) {
server = &Server{
stopChan: make(chan struct{}),
......@@ -106,6 +109,7 @@ func wildcardCors(w http.ResponseWriter, r *http.Request) {
}
}
// Starts server
func (s *Server) Start() <-chan error {
go repository.Outdate(s.outdaters, time.Minute, s.stopChan)
......@@ -118,12 +122,14 @@ func (s *Server) Start() <-chan error {
return s.errChan
}
// Stops server
func (s *Server) Stop(timeout time.Duration) {
close(s.stopChan)
s.waitAll(timeout)
s.Close()
}
// Returns true if server is active
func (s *Server) Active() bool {
select {
case <-s.stopChan:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment