File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 5
5
"html/template"
6
6
"net/http"
7
7
"regexp"
8
+ "sync"
8
9
9
10
"github.com/gobuffalo/buffalo"
10
11
"github.com/swaggo/swag"
@@ -13,6 +14,8 @@ import (
13
14
14
15
// WrapHandler wraps `http.Handler` into `buffalo.Handler`.
15
16
func WrapHandler (h * webdav.Handler ) buffalo.Handler {
17
+ var once sync.Once
18
+
16
19
//create a template with name
17
20
t := template .New ("swagger_index.html" )
18
21
index , _ := t .Parse (swagger_index_templ )
@@ -29,8 +32,10 @@ func WrapHandler(h *webdav.Handler) buffalo.Handler {
29
32
return c .Error (http .StatusNotFound , errors .New ("404 page not found" ))
30
33
}
31
34
path := matches [2 ]
32
- prefix := matches [1 ]
33
- h .Prefix = prefix
35
+
36
+ once .Do (func () {
37
+ h .Prefix = matches [1 ]
38
+ })
34
39
35
40
switch path {
36
41
case "index.html" :
@@ -51,8 +56,8 @@ func WrapHandler(h *webdav.Handler) buffalo.Handler {
51
56
h .ServeHTTP (c .Response (), c .Request ())
52
57
default :
53
58
h .ServeHTTP (c .Response (), c .Request ())
54
-
55
59
}
60
+
56
61
return nil
57
62
}
58
63
return fn
You can’t perform that action at this time.
0 commit comments