diff options
Diffstat (limited to 'internal')
-rw-r--r-- | internal/serving/disk/serving.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/internal/serving/disk/serving.go b/internal/serving/disk/serving.go index db184d3c..430aa95f 100644 --- a/internal/serving/disk/serving.go +++ b/internal/serving/disk/serving.go @@ -5,14 +5,16 @@ import ( "gitlab.com/gitlab-org/gitlab-pages/internal/serving" ) -// Serving describes a disk access serving -type Serving struct { +var disk *Disk + +// Disk describes a disk access serving +type Disk struct { Reader } // ServeFileHTTP serves a file from disk and returns true. It returns false // when a file could not been found. -func (s *Serving) ServeFileHTTP(h serving.Handler) bool { +func (s *Disk) ServeFileHTTP(h serving.Handler) bool { if s.tryFile(h) == nil { return true } @@ -21,7 +23,7 @@ func (s *Serving) ServeFileHTTP(h serving.Handler) bool { } // ServeNotFoundHTTP tries to read a custom 404 page -func (s *Serving) ServeNotFoundHTTP(h serving.Handler) { +func (s *Disk) ServeNotFoundHTTP(h serving.Handler) { if s.tryNotFound(h) == nil { return } @@ -33,5 +35,9 @@ func (s *Serving) ServeNotFoundHTTP(h serving.Handler) { // New returns a serving instance that is capable of reading files // from the disk func New() serving.Serving { - return &Serving{} + if disk == nil { + disk = &Disk{} + } + + return disk } |