github.com/cloud-foundations/dominator@v0.0.0-20221004181915-6e4fee580046/sub/httpd/status.go (about)

     1  package httpd
     2  
     3  import (
     4  	"bufio"
     5  	"fmt"
     6  	"net/http"
     7  
     8  	"github.com/Cloud-Foundations/Dominator/lib/html"
     9  	"github.com/Cloud-Foundations/Dominator/lib/srpc"
    10  )
    11  
    12  func statusHandler(w http.ResponseWriter, req *http.Request) {
    13  	if req.URL.Path != "/" {
    14  		http.NotFound(w, req)
    15  		return
    16  	}
    17  	writer := bufio.NewWriter(w)
    18  	defer writer.Flush()
    19  	fmt.Fprintln(writer, "<title>subd status page</title>")
    20  	fmt.Fprintln(writer, "<body>")
    21  	fmt.Fprintln(writer, "<center>")
    22  	fmt.Fprintln(writer, "<h1>subd status page</h1>")
    23  	if !srpc.CheckTlsRequired() {
    24  		fmt.Fprintln(writer,
    25  			`<h1><font color="red">Running in insecure mode. You can get pwned!!!</font></h1>`)
    26  	}
    27  	fmt.Fprintln(writer, "</center>")
    28  	html.WriteHeaderWithRequest(writer, req)
    29  	fmt.Fprintln(writer, "<h3>")
    30  	for _, htmlWriter := range htmlWriters {
    31  		htmlWriter.WriteHtml(writer)
    32  	}
    33  	fmt.Fprintln(writer, "</h3>")
    34  	fmt.Fprintln(writer, "<hr>")
    35  	html.WriteFooter(writer)
    36  	fmt.Fprintln(writer, "</body>")
    37  }