V
V
Vadim Rublev2020-01-25 18:43:44
go
Vadim Rublev, 2020-01-25 18:43:44

How to specify a shared directory on the server plus a personal one?

There is a regular routing on the Go server:

http.Handle("/", http.FileServer(http.Dir("c:/serverGo/www/site.com/")))

http.HandleFunc("/about", func(w http.ResponseWriter, r *http.Request) {
  http.ServeFile(w, r, "c:/serverGo/www/site.com/about.html")
})

http.HandleFunc("/blog/", func(w http.ResponseWriter, r *http.Request) {
        // Тут контроль последнего элемента в Пути_URL'а; и если это "345", то:
  http.ServeFile(w, r, "c:/serverGo/www/site.com/345.html")
})

The URL site.com or site.com/about opens the page file /index or /about, along with their CSS file - which is requested by the URL site.com/css/style.css (all files are in the root of the site).
But the URL site.com/blog/345 opens the file /my345.hyml - as intended, but its CSS file cannot be pulled up - which is requested by the URL site.com/blog/css/style.css , and lies there same. This is where the directory breaks (relative to the site root specified in the first handler for all requests). I have already duplicated all the files in all directories ... - in none! :(
How to slip a CSS file directory along with the /blog/ route?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question