-
Notifications
You must be signed in to change notification settings - Fork 0
/
web.go
69 lines (56 loc) · 1.07 KB
/
web.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package web
import (
"context"
"net/http"
"github.com/cs3org/reva"
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/rhttp/global"
"github.com/cs3org/reva/pkg/utils/cfg"
"github.com/rs/zerolog"
)
func init() {
reva.RegisterPlugin(web{})
}
type web struct {
log *zerolog.Logger
c *config
}
func (web) RevaPlugin() reva.PluginInfo {
return reva.PluginInfo{
ID: "http.services.web",
New: New,
}
}
type config struct {
Prefix string `mapstructure:"prefix"`
}
func (c *config) ApplyDefaults() {
if c.Prefix == "" {
c.Prefix = "web"
}
}
func New(ctx context.Context, m map[string]interface{}) (global.Service, error) {
var c config
if err := cfg.Decode(m, &c); err != nil {
return nil, err
}
log := appctx.GetLogger(ctx)
e := &web{
log: log,
c: &c,
}
return e, nil
}
func (e *web) Handler() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
})
}
func (e *web) Prefix() string {
return e.c.Prefix
}
func (e *web) Close() error {
return nil
}
func (e *web) Unprotected() []string {
return nil
}