By writing the corresponding code :) For example: package main
import ( "log" "net/http" ) func ServeIndex(res http.ResponseWriter, req *http.Request) { http.ServeFile(res, req, "index.html") } func main() { http.HandleFunc("/", ServeIndex) http.Handle("/img/", http.StripPrefix("/img/", http.FileServer(http.Dir("img")))) http.Handle("/js/", http.StripPrefix("/js/", http.FileServer(http.Dir("js")))) http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir("css")))) log.Fatal(http.ListenAndServe(":8080", nil)) } Now, if you need more complicated logic, you need to write more complicated code. But hopefully, this will give you some idea of how to compose different handlers and where to start. On Thu, Mar 9, 2017 at 7:51 AM, <so.qu...@gmail.com> wrote: > In my handler I want to return a single webpage. > > But when using http.ServeFile, the images on the page aren't rendered. > https://golang.org/pkg/net/http/#ServeFile > > And using http.FileServer, returns a handler that renders an entire > directory (and children) > https://golang.org/pkg/net/http/#FileServer > > How would I respond back with a single webpage and all its images, js and > css? > Also the images, js and css are in different folders. > > > > > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.