diff options
author | Matthew Holt <[email protected]> | 2019-08-09 12:05:47 -0600 |
---|---|---|
committer | Matthew Holt <[email protected]> | 2019-08-09 12:05:47 -0600 |
commit | ab885f07b844fd60adb9d49ed7884f3cd2d939a7 (patch) | |
tree | 8827ad88cf3da8982154e2fda46f53274342785d /modules.go | |
parent | 4950ce485f7d931890fcfd2ee287b6df1b5db435 (diff) | |
download | caddy-ab885f07b844fd60adb9d49ed7884f3cd2d939a7.tar.gz caddy-ab885f07b844fd60adb9d49ed7884f3cd2d939a7.zip |
Implement config adapters and beginning of Caddyfile adapter
Along with several other changes, such as renaming caddyhttp.ServerRoute
to caddyhttp.Route, exporting some types that were not exported before,
and tweaking the caddytls TLS values to be more consistent.
Notably, we also now disable automatic cert management for names which
already have a cert (manually) loaded into the cache. These names no
longer need to be specified in the "skip_certificates" field of the
automatic HTTPS config, because they will be skipped automatically.
Diffstat (limited to 'modules.go')
-rw-r--r-- | modules.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/modules.go b/modules.go index a257a69ac..f1b47659a 100644 --- a/modules.go +++ b/modules.go @@ -38,6 +38,26 @@ type Module struct { New func() interface{} } +// ID returns a module's ID, which is the +// last element of its name. +func (m Module) ID() string { + if m.Name == "" { + return "" + } + parts := strings.Split(m.Name, ".") + return parts[len(parts)-1] +} + +// Namespace returns the module's namespace (scope) +// which is all but the last element of its name. +func (m Module) Namespace() string { + lastDot := strings.LastIndex(m.Name, ".") + if lastDot < 0 { + return "" + } + return m.Name[:lastDot] +} + func (m Module) String() string { return m.Name } // RegisterModule registers a module. Modules must call |