Skip to content

Commit ce102e5

Browse files
committed
report e-dant/watcher, dunglas/caddy-cbrotli, libbrotli and dunglas/mercure versions
1 parent 922de2d commit ce102e5

3 files changed

Lines changed: 54 additions & 0 deletions

File tree

caddy/br.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,33 @@
22

33
package caddy
44

5+
// #include <brotli/encode.h>
6+
import "C"
7+
8+
import (
9+
"fmt"
10+
"runtime/debug"
11+
12+
"github.com/dunglas/frankenphp"
13+
)
14+
515
var brotli = true
16+
17+
func init() {
18+
brotliVer := C.BrotliEncoderVersion()
19+
if brotliVer != 0 {
20+
major := int(brotliVer >> 24)
21+
minor := int((brotliVer >> 12) & 0xfff)
22+
patch := int(brotliVer & 0xfff)
23+
frankenphp.AddPhpinfoEntry("libbrotli", fmt.Sprintf("%d.%d.%d", major, minor, patch))
24+
}
25+
26+
if buildInfo, ok := debug.ReadBuildInfo(); ok {
27+
for _, dep := range buildInfo.Deps {
28+
if dep.Path == "github.com/dunglas/caddy-cbrotli" {
29+
frankenphp.AddPhpinfoEntry("dunglas/caddy-cbrotli", dep.Version)
30+
break
31+
}
32+
}
33+
}
34+
}

mercure.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,23 @@ package frankenphp
88
import "C"
99
import (
1010
"log/slog"
11+
"runtime/debug"
1112
"unsafe"
1213

1314
"github.com/dunglas/mercure"
1415
)
1516

17+
func init() {
18+
if buildInfo, ok := debug.ReadBuildInfo(); ok {
19+
for _, dep := range buildInfo.Deps {
20+
if dep.Path == "github.com/dunglas/mercure" {
21+
AddPhpinfoEntry("dunglas/mercure", dep.Version)
22+
break
23+
}
24+
}
25+
}
26+
}
27+
1628
type mercureContext struct {
1729
mercureHub *mercure.Hub
1830
}

watcher.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,25 @@
33
package frankenphp
44

55
import (
6+
"runtime/debug"
67
"sync/atomic"
78

89
"github.com/dunglas/frankenphp/internal/watcher"
910
watcherGo "github.com/e-dant/watcher/watcher-go"
1011
)
1112

13+
func init() {
14+
// watcher doesn't expose the version, so get it from go.mod
15+
if buildInfo, ok := debug.ReadBuildInfo(); ok {
16+
for _, dep := range buildInfo.Deps {
17+
if dep.Path == "github.com/e-dant/watcher" {
18+
AddPhpinfoEntry("e-dant/watcher", dep.Version)
19+
break
20+
}
21+
}
22+
}
23+
}
24+
1225
type hotReloadOpt struct {
1326
hotReload []*watcher.PatternGroup
1427
}

0 commit comments

Comments
 (0)