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

     1  package httpd
     2  
     3  import (
     4  	"bufio"
     5  	"fmt"
     6  	"io"
     7  	"net/http"
     8  
     9  	"github.com/Cloud-Foundations/Dominator/lib/html"
    10  )
    11  
    12  func (s state) 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>imaginator status page</title>")
    20  	fmt.Fprintln(writer, `<style>
    21                            table, th, td {
    22                            border-collapse: collapse;
    23                            }
    24                            </style>`)
    25  	fmt.Fprintln(writer, "<body>")
    26  	fmt.Fprintln(writer, "<center>")
    27  	fmt.Fprintln(writer, "<h1>imaginator status page</h1>")
    28  	fmt.Fprintln(writer, "</center>")
    29  	html.WriteHeaderWithRequest(writer, req)
    30  	fmt.Fprintln(writer, "<h3>")
    31  	s.writeDashboard(writer)
    32  	for _, htmlWriter := range htmlWriters {
    33  		htmlWriter.WriteHtml(writer)
    34  	}
    35  	fmt.Fprintln(writer, "</h3>")
    36  	fmt.Fprintln(writer, "<hr>")
    37  	html.WriteFooter(writer)
    38  	fmt.Fprintln(writer, "</body>")
    39  }
    40  
    41  func (s state) writeDashboard(writer io.Writer) {
    42  }