Documentation ¶
Overview ¶
Package server provides a sample HTTP/Websocket server which registers itself in consul using one or more url prefixes to demonstrate and test the automatic fabio routing table update.
During startup the server performs the following steps:
- Add a handler for each prefix which provides a unique response for that instance and endpoint
- Add a `/health` handler for the consul health check
- Register the service in consul with the listen address, a health check under the given name and with one `urlprefix-` tag per prefix
- Install a signal handler to deregister the service on exit
If the protocol is set to "ws" the registered endpoints function as websocket echo servers.
Example:
# http server ./server -addr 127.0.0.1:5000 -name svc-a -prefix /foo -prefix /bar ./server -addr 127.0.0.1:5001 -name svc-b -prefix /baz -prefix /bar ./server -addr 127.0.0.1:5002 -name svc-c -prefix "/gogl redirect=301,https://www.google.de/" # https server ./server -addr 127.0.0.1:5000 -name svc-a -proto https -certFile ... -keyFile ... -prefix /foo ./server -addr 127.0.0.1:5000 -name svc-a -proto https -certFile ... -keyFile ... -prefix "/foo tlsskipverify=true" # websocket server ./server -addr 127.0.0.1:6000 -name ws-a -proto ws -prefix /echo1 -prefix /echo2 # tcp server ./server -addr 127.0.0.1:7000 -name tcp-a -proto tcp -prefix :1234
Click to show internal directories.
Click to hide internal directories.