forked from andreaskoch/allmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider.go
40 lines (32 loc) · 1.11 KB
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2014 Andreas Koch. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package webpaths
import (
"github.com/andreaskoch/allmark/common/paths"
"github.com/andreaskoch/allmark/common/route"
)
type WebPathProvider struct {
patherFactory paths.PatherFactory
itemPather paths.Pather
tagPather paths.Pather
}
func NewWebPathProvider(patherFactory paths.PatherFactory, basePath, tagPathPrefix string) WebPathProvider {
return WebPathProvider{
patherFactory: patherFactory,
itemPather: patherFactory.Absolute(basePath),
tagPather: patherFactory.Absolute(tagPathPrefix),
}
}
func (provider *WebPathProvider) AbsolutePather(prefix string) paths.Pather {
return provider.patherFactory.Absolute(prefix)
}
func (provider *WebPathProvider) ItemPather() paths.Pather {
return provider.itemPather
}
func (provider *WebPathProvider) TagPather() paths.Pather {
return provider.tagPather
}
func (provider *WebPathProvider) RelativePather(baseRoute route.Route) paths.Pather {
return provider.patherFactory.Relative(baseRoute)
}