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

     1  package httpd
     2  
     3  import (
     4  	"bufio"
     5  	"fmt"
     6  	"net/http"
     7  )
     8  
     9  func (s state) showFileSystemHandler(w http.ResponseWriter, req *http.Request) {
    10  	writer := bufio.NewWriter(w)
    11  	defer writer.Flush()
    12  	streamName := req.URL.RawQuery
    13  	fmt.Fprintf(writer, "<title>scanned stream  %s</title>\n", streamName)
    14  	fmt.Fprintln(writer, "<body>")
    15  	fmt.Fprintln(writer, "<h3>")
    16  	fs, err := s.unpacker.GetFileSystem(streamName)
    17  	if err != nil {
    18  		fmt.Fprintln(writer, err)
    19  	} else if fs == nil {
    20  		fmt.Fprintln(writer, "No scanned file system")
    21  	} else {
    22  		fmt.Fprintf(writer, "Scanned file-system for stream: %s\n", streamName)
    23  		fmt.Fprintln(writer, "</h3>")
    24  		fmt.Fprintln(writer, "<pre>")
    25  		fs.List(writer)
    26  		fmt.Fprintln(writer, "</pre>")
    27  	}
    28  	fmt.Fprintln(writer, "</body>")
    29  }