-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.go
39 lines (33 loc) · 790 Bytes
/
init.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
package stgin
import (
"github.com/AminMal/slogger"
"regexp"
"runtime"
"strings"
)
var stginLogger slogger.Logger
var contentTypeKey = "Content-Type"
var applicationJsonType = "application/json"
var multipleSlashesRegex *regexp.Regexp
func init() {
stginLogger = slogger.GetLogger("STGIN")
multipleSlashesRegex = regexp.MustCompile("(/{2,})")
}
func normalizePath(path string) string {
return multipleSlashesRegex.ReplaceAllString(path, "/")
}
func relevantCallers() []runtime.Frame {
pc := make([]uintptr, 16)
n := runtime.Callers(1, pc)
frames := runtime.CallersFrames(pc[:n])
var fs []runtime.Frame
for {
f, more := frames.Next()
if more && !strings.HasPrefix(f.Function, "github.com/AminMal/stgin.") {
fs = append(fs, f)
} else {
break
}
}
return fs
}