Skip to content

Commit

Permalink
caddyconfig: Minor internal and godoc tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
mholt committed May 29, 2020
1 parent 9415fec commit 6c051cd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
15 changes: 7 additions & 8 deletions caddyconfig/configadapters.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,13 @@ func JSON(val interface{}, warnings *[]Warning) json.RawMessage {
return b
}

// 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.
// This is useful for JSON-encoding module values where the module name has to
// be described within the object by a certain key; for example,
// "responder": "file_server" for a file server HTTP responder. The val must
// encode into a map[string]interface{} (i.e. it must be a struct or map),
// and any errors are converted into warnings, so this can be conveniently
// used when filling a struct. For correct code, there should be no errors.
// JSONModuleObject is like JSON(), except it marshals val into a JSON object
// with an added key named fieldName with the value fieldVal. This is useful
// for encoding module values where the module name has to be described within
// the object by a certain key; for example, `"handler": "file_server"` for a
// file server HTTP handler (fieldName="handler" and fieldVal="file_server").
// The val parameter must encode into a map[string]interface{} (i.e. it must be
// a struct or map). Any errors are converted into warnings.
func JSONModuleObject(val interface{}, fieldName, fieldVal string, warnings *[]Warning) json.RawMessage {
// encode to a JSON object first
enc, err := json.Marshal(val)
Expand Down
4 changes: 2 additions & 2 deletions caddyconfig/httpcaddyfile/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,13 @@ func parseTLS(h Helper) ([]ConfigValue, error) {
// certificate loaders
if len(fileLoader) > 0 {
configVals = append(configVals, ConfigValue{
Class: "tls.certificate_loader",
Class: "tls.cert_loader",
Value: fileLoader,
})
}
if len(folderLoader) > 0 {
configVals = append(configVals, ConfigValue{
Class: "tls.certificate_loader",
Class: "tls.cert_loader",
Value: folderLoader,
})
}
Expand Down
2 changes: 1 addition & 1 deletion caddyconfig/httpcaddyfile/tlsapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (st ServerType) buildTLSApp(
}

// certificate loaders
if clVals, ok := sblock.pile["tls.certificate_loader"]; ok {
if clVals, ok := sblock.pile["tls.cert_loader"]; ok {
for _, clVal := range clVals {
certLoaders = append(certLoaders, clVal.Value.(caddytls.CertificateLoader))
}
Expand Down
4 changes: 1 addition & 3 deletions modules/logging/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ func init() {
}

// LogFieldFilter can filter (or manipulate)
// a field in a log entry. If delete is true,
// out will be ignored and the field will be
// removed from the output.
// a field in a log entry.
type LogFieldFilter interface {
Filter(zapcore.Field) zapcore.Field
}
Expand Down

0 comments on commit 6c051cd

Please sign in to comment.