diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2020-02-03 18:17:56 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2020-02-05 14:00:21 +0300 |
commit | 4d5764a77935ef502e34fed33f74e69ba1cebc6b (patch) | |
tree | c17b25be29c63ab9c3613f548f89b27153d2d552 /internal/domain | |
parent | 57a8b1184da1d53184aad5d4f0bedea51d330b1a (diff) |
Add support for per-lookup-path domain serving
Diffstat (limited to 'internal/domain')
-rw-r--r-- | internal/domain/domain.go | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/internal/domain/domain.go b/internal/domain/domain.go index 28eb3196..6e6ffde0 100644 --- a/internal/domain/domain.go +++ b/internal/domain/domain.go @@ -19,8 +19,6 @@ type Domain struct { Resolver Resolver - serving serving.Serving - certificate *tls.Certificate certificateError error certificateOnce sync.Once @@ -57,16 +55,8 @@ func (d *Domain) GetLookupPath(r *http.Request) *serving.LookupPath { return lookupPath } -// Serving returns domain serving driver -func (d *Domain) Serving() serving.Serving { - if d.serving == nil { - d.serving = disk.New() - } - - return d.serving -} - -func (d *Domain) toHandler(w http.ResponseWriter, r *http.Request) serving.Handler { +// Handler returns a serving handler for this request +func (d *Domain) Handler(w http.ResponseWriter, r *http.Request) serving.Handler { project, subpath := d.resolve(r) return serving.Handler{ @@ -74,6 +64,7 @@ func (d *Domain) toHandler(w http.ResponseWriter, r *http.Request) serving.Handl Request: r, LookupPath: project, SubPath: subpath, + Serving: disk.New(), } } @@ -168,7 +159,8 @@ func (d *Domain) ServeFileHTTP(w http.ResponseWriter, r *http.Request) bool { return true } - return d.Serving().ServeFileHTTP(d.toHandler(w, r)) + return d.Handler(w, r).ServeFileHTTP() + //d.Serving().ServeFileHTTP(d.toHandler(w, r)) } // ServeNotFoundHTTP serves the not found pages from the projects. @@ -178,5 +170,6 @@ func (d *Domain) ServeNotFoundHTTP(w http.ResponseWriter, r *http.Request) { return } - d.Serving().ServeNotFoundHTTP(d.toHandler(w, r)) + d.Handler(w, r).ServeNotFoundHTTP() + //d.Serving().ServeNotFoundHTTP(d.toHandler(w, r)) } |