all: imp docs

This commit is contained in:
Stanislav Chzhen 2025-09-25 15:51:00 +03:00
parent 1c833fafdd
commit 6c5bcbb31b
3 changed files with 8 additions and 12 deletions

View File

@ -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,

View File

@ -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)

View File

@ -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
}