Skip to content

Commit ea4fd3d

Browse files
committed
Add /health and server version.
1 parent b5212d6 commit ea4fd3d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/servian/https-echo
2+
3+
go 1.12

main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ package main
33
import (
44
"flag"
55
"fmt"
6+
"io"
67
"log"
78
"net/http"
89
"os"
910
"strings"
1011
)
1112

1213
// Version number constant.
13-
const Version = "0.0.4"
14+
const Version = "0.0.5"
1415

1516
// Homepage url.
1617
const Homepage = "https://github.com/servian/https-echo"
@@ -22,6 +23,11 @@ var (
2223
)
2324

2425
func redirect(w http.ResponseWriter, req *http.Request) {
26+
w.Header().Set("Server", "Https-echo/"+Version+" (+"+Homepage+")")
27+
if "/health" == req.URL.Path {
28+
io.WriteString(w, "Healthy.\n")
29+
return
30+
}
2531
hostname := strings.Split(req.Host, ":")
2632
dps := ""
2733
if *destPort > 0 {

0 commit comments

Comments
 (0)