Servir contenido estático con una URL raíz con el kit de herramientas de Gorilla
Estoy intentando usar el kit de herramientas de Gorillamux
paquete para enrutar direcciones URL en un servidor web Go. Utilizandoesta pregunta Como guía tengo el siguiente código Go:
func main() {
r := mux.NewRouter()
r.Handle("/", http.FileServer(http.Dir("./static/")))
r.HandleFunc("/search/{searchTerm}", Search)
r.HandleFunc("/load/{dataId}", Load)
http.Handle("/", r)
http.ListenAndServe(":8100", nil)
}
La estructura del directorio es:
...
main.go
static\
| index.html
| js\
| <js files>
| css\
| <css files>
Los archivos Javascript y CSS están referenciados enindex.html
Me gusta esto:
...
<link rel="stylesheet" href="css/redmond/jquery-ui.min.css"/>
<script src="js/jquery.min.js"></script>
...
Cuando accedohttp://localhost:8100
en mi navegador web elindex.html
El contenido se entrega con éxito, sin embargo, todos losjs
ycss
URLs devuelven 404s.
¿Cómo puedo obtener el programa para servir archivos destatic
subdirectorios?