func WithDomainPrefix()

in service/middleware/middleware.go [40:54]


func WithDomainPrefix(h http.Handler) http.HandlerFunc {
	return func(resp http.ResponseWriter, req *http.Request) {
		host, _, _ := strings.Cut(req.Host, ":")
		path := req.URL.Path
		req.URL.Path = host + path

		if strings.HasSuffix(path, "/") {
			req.URL.Path += "index.html"
		}

		log.Printf("updated req path is: %s", req.URL.Path)

		h.ServeHTTP(resp, req)
	}
}