Browse Source

caddyconfig: Minor internal and godoc tweaks

master
Matthew Holt 5 years ago
parent
commit
6c051cd27d
  1. 15
      caddyconfig/configadapters.go
  2. 4
      caddyconfig/httpcaddyfile/builtins.go
  3. 2
      caddyconfig/httpcaddyfile/tlsapp.go
  4. 4
      modules/logging/filters.go

15
caddyconfig/configadapters.go

@ -51,14 +51,13 @@ func JSON(val interface{}, warnings *[]Warning) json.RawMessage {
return b return b
} }
// JSONModuleObject is like JSON, except it marshals val into a JSON object // JSONModuleObject is like JSON(), except it marshals val into a JSON object
// and then adds a key to that object named fieldName with the value fieldVal. // with an added key named fieldName with the value fieldVal. This is useful
// This is useful for JSON-encoding module values where the module name has to // for encoding module values where the module name has to be described within
// be described within the object by a certain key; for example, // the object by a certain key; for example, `"handler": "file_server"` for a
// "responder": "file_server" for a file server HTTP responder. The val must // file server HTTP handler (fieldName="handler" and fieldVal="file_server").
// encode into a map[string]interface{} (i.e. it must be a struct or map), // The val parameter must encode into a map[string]interface{} (i.e. it must be
// and any errors are converted into warnings, so this can be conveniently // a struct or map). Any errors are converted into warnings.
// used when filling a struct. For correct code, there should be no errors.
func JSONModuleObject(val interface{}, fieldName, fieldVal string, warnings *[]Warning) json.RawMessage { func JSONModuleObject(val interface{}, fieldName, fieldVal string, warnings *[]Warning) json.RawMessage {
// encode to a JSON object first // encode to a JSON object first
enc, err := json.Marshal(val) enc, err := json.Marshal(val)

4
caddyconfig/httpcaddyfile/builtins.go

@ -259,13 +259,13 @@ func parseTLS(h Helper) ([]ConfigValue, error) {
// certificate loaders // certificate loaders
if len(fileLoader) > 0 { if len(fileLoader) > 0 {
configVals = append(configVals, ConfigValue{ configVals = append(configVals, ConfigValue{
Class: "tls.certificate_loader", Class: "tls.cert_loader",
Value: fileLoader, Value: fileLoader,
}) })
} }
if len(folderLoader) > 0 { if len(folderLoader) > 0 {
configVals = append(configVals, ConfigValue{ configVals = append(configVals, ConfigValue{
Class: "tls.certificate_loader", Class: "tls.cert_loader",
Value: folderLoader, Value: folderLoader,
}) })
} }

2
caddyconfig/httpcaddyfile/tlsapp.go

@ -233,7 +233,7 @@ func (st ServerType) buildTLSApp(
} }
// certificate loaders // certificate loaders
if clVals, ok := sblock.pile["tls.certificate_loader"]; ok { if clVals, ok := sblock.pile["tls.cert_loader"]; ok {
for _, clVal := range clVals { for _, clVal := range clVals {
certLoaders = append(certLoaders, clVal.Value.(caddytls.CertificateLoader)) certLoaders = append(certLoaders, clVal.Value.(caddytls.CertificateLoader))
} }

4
modules/logging/filters.go

@ -27,9 +27,7 @@ func init() {
} }
// LogFieldFilter can filter (or manipulate) // LogFieldFilter can filter (or manipulate)
// a field in a log entry. If delete is true, // a field in a log entry.
// out will be ignored and the field will be
// removed from the output.
type LogFieldFilter interface { type LogFieldFilter interface {
Filter(zapcore.Field) zapcore.Field Filter(zapcore.Field) zapcore.Field
} }

Loading…
Cancel
Save