Search code examples
gostatic-filesmux

Golang Static folder path returns all files


i have a this code to open static folder

fs := http.FileServer(http.Dir("./static/"))
router.PathPrefix("/static/").Handler(http.StripPrefix("/static/", fs))

but when i'm going to /static path it returns a list of files in this folder

eg

license.txt
logo.png

but i want to return a blank page


Solution

  • You can add blank index.html in directory ./static/, it will be rendered as blank page.

    Something like this

    <html>
    <head><title>Nothing here</title></head>
    <body><h1>Nothing here</h1></body>
    </html>