@marcel91200 / caddy Mirror · read-only / commits / ccb5d19c
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

Get module name at runtime, and tidy up modules

Matthew Holt committed Jul 12, 2019 at 10:15 UTC ccb5d19c258a1f4ec87ec7cdc4aedf1f1c7007dc
4 files changed +9 -12
caddy.go
+7 -8
@@ -209,24 +209,23 @@ func (d *Duration) UnmarshalJSON(b []byte) error {
209 // value will still be returned, but with an
210 // unknown version.
211 func GoModule() *debug.Module {
212 + mod := &debug.Module{Version: "unknown"}
213 bi, ok := debug.ReadBuildInfo()
214 if ok {
215 + mod.Path = bi.Main.Path
216 // The recommended way to build Caddy involves
217 // creating a separate main module, which
218 // TODO: track related Go issue: https://github.com/golang/go/issues/29228
217 - for _, mod := range bi.Deps {
218 - if mod.Path == goModule {
219 - return mod
219 + // once that issue is fixed, we should just be able to use bi.Main... hopefully.
220 + for _, dep := range bi.Deps {
221 + if dep.Path == mod.Path {
222 + return dep
223 }
224 }
225 }
223 - return &debug.Module{Version: "unknown"}
226 + return mod
227 }
228
226 -// goModule is the name of this Go module.
227 -// TODO: we should be able to find this at runtime, see https://github.com/golang/go/issues/29228
228 -const goModule = "github.com/caddyserver/caddy/v2"
229 -
229 // CtxKey is a value type for use with context.WithValue.
230 type CtxKey string
231
go.sum
-2
@@ -6,8 +6,6 @@ github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITg
6 github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
7 github.com/Masterminds/sprig v2.20.0+incompatible h1:dJTKKuUkYW3RMFdQFXPU/s6hg10RgctmTjRcbZ98Ap8=
8 github.com/Masterminds/sprig v2.20.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
9 -github.com/andybalholm/brotli v0.0.0-20190430215306-5c318f9037cb h1:Qs8/an94NFS1x2nn7rSI+skKFuw/EGfEYAGS3w/p+jc=
10 -github.com/andybalholm/brotli v0.0.0-20190430215306-5c318f9037cb/go.mod h1:+lx6/Aqd1kLJ1GQfkvOnaZ1WGmLpMpbprPuIOOZX30U=
9 github.com/andybalholm/brotli v0.0.0-20190704151324-71eb68cc467c h1:pBKtfXLqKZ+GPHGjlBheGaXK2lddydUG3XhWGrYjxOA=
10 github.com/andybalholm/brotli v0.0.0-20190704151324-71eb68cc467c/go.mod h1:+lx6/Aqd1kLJ1GQfkvOnaZ1WGmLpMpbprPuIOOZX30U=
11 github.com/cenkalti/backoff v2.1.1+incompatible h1:tKJnvO2kl0zmb/jA5UKAt4VoEVw1qxKWjE/Bpp46npY=
modules/caddyhttp/fileserver/matcher.go
+1 -1
@@ -20,8 +20,8 @@ import (
20 "os"
21 "time"
22
23 - "github.com/caddyserver/caddy/modules/caddyhttp"
23 "github.com/caddyserver/caddy/v2"
24 + "github.com/caddyserver/caddy/v2/modules/caddyhttp"
25 )
26
27 func init() {
modules/caddyhttp/reverseproxy/upstream.go
+1 -1
@@ -28,8 +28,8 @@ import (
28 "sync/atomic"
29 "time"
30
31 - "github.com/caddyserver/caddy/modules/caddyhttp"
31 "github.com/caddyserver/caddy/v2"
32 + "github.com/caddyserver/caddy/v2/modules/caddyhttp"
33 )
34
35 // CircuitBreaker defines the functionality of a circuit breaker module.