mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-10-26 11:27:18 +00:00
all: imp docs
This commit is contained in:
parent
1c833fafdd
commit
6c5bcbb31b
@ -23,7 +23,7 @@ type RegisterFunc func(method, url string, handler http.HandlerFunc)
|
||||
// OK writes "OK\n" to the response. l and w must not be nil.
|
||||
func OK(ctx context.Context, l *slog.Logger, w http.ResponseWriter) {
|
||||
if _, err := io.WriteString(w, "OK\n"); err != nil {
|
||||
l.ErrorContext(ctx, "could not write body", slogutil.KeyError, err)
|
||||
l.WarnContext(ctx, "writing ok body", slogutil.KeyError, err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ func ErrorAndLog(
|
||||
args ...any,
|
||||
) {
|
||||
text := fmt.Sprintf(format, args...)
|
||||
l.ErrorContext(
|
||||
l.WarnContext(
|
||||
ctx,
|
||||
"http error",
|
||||
"host", r.Host,
|
||||
|
||||
@ -308,7 +308,7 @@ func initContextClients(
|
||||
config.DHCP.DataDir = globalContext.getDataDir()
|
||||
config.DHCP.HTTPRegister = httpRegister
|
||||
config.DHCP.CommandConstructor = executil.SystemCommandConstructor{}
|
||||
config.DHCP.Logger = logger.With(slogutil.KeyPrefix, "dhcp_server")
|
||||
config.DHCP.Logger = logger.With(slogutil.KeyPrefix, "dhcpd")
|
||||
config.DHCP.ConfModifier = confModifier
|
||||
|
||||
globalContext.dhcpServer, err = dhcpd.Create(config.DHCP)
|
||||
|
||||
@ -443,15 +443,11 @@ func (m *tlsManager) handleTLSValidate(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
setts, err := unmarshalTLS(r)
|
||||
if err != nil {
|
||||
aghhttp.ErrorAndLog(
|
||||
ctx,
|
||||
m.logger,
|
||||
r,
|
||||
w,
|
||||
http.StatusBadRequest,
|
||||
"Failed to unmarshal TLS config: %s",
|
||||
err,
|
||||
)
|
||||
// errFmt does not follow error message guidelines because it is sent
|
||||
// directly to the frontend.
|
||||
const errFmt = "Failed to unmarshal TLS config: %s"
|
||||
|
||||
aghhttp.ErrorAndLog(ctx, m.logger, r, w, http.StatusBadRequest, errFmt, err)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user