blob: c9388701d7dc4bd3c0228f337a4315feb646fa05 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
package server
import (
"net/http"
"github.com/LMBishop/scrapbook/pkg/html"
"github.com/LMBishop/scrapbook/pkg/index"
)
func ServeSite(siteIndex *index.SiteIndex) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
site := siteIndex.GetSiteByHost(r.Host)
if site == nil {
w.WriteHeader(http.StatusNotFound)
html.NotFoundSitePage(r.Host).Render(w)
return
}
site.Handler.ServeHTTP(w, r)
}
}
|