package web
import (
"strconv"
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
)
// EvidenceView shows what a checker saw of one HTTP exchange.
type EvidenceView struct {
MonitorID string
MonitorName string
Time string
Region string
OK bool
Error string
// FailedAt is the catalog key of the stage a failed exchange stopped
// in, or empty.
FailedAt string
RemoteAddr string
Phases []TimingPhase
Total string
Steps []EvidenceStep
TLS *TLSView
ContentType string
Body string
Truncated bool
Binary bool
}
// TimingPhase is one part of the request time; Percent sizes its bar.
type TimingPhase struct {
Key string
Value string
Percent float64
}
// EvidenceStep is one request and response of the redirect chain.
type EvidenceStep struct {
Method string
URL string
Status string
Proto string
RequestHeaders [][2]string
ResponseHeaders [][2]string
}
// TLSView describes the server certificate.
type TLSView struct {
Version string
Cipher string
Subject string
Issuer string
Names string
NotBefore string
NotAfter string
DaysLeft int
}
// EvidenceRow links to evidence from the monitor page.
type EvidenceRow struct {
URL string
Time string
Region string
OK bool
Detail string
}
templ evidenceList(rows []EvidenceRow) {
{ i18n.T(ctx, "evidence.intro") }
for _, r := range rows {
| { h[0] } | { h[1] } |
{ v.Time } · { v.Region } if v.RemoteAddr != "" { { " · " + v.RemoteAddr } }
if !v.OK {{ v.Error } if v.FailedAt != "" { { i18n.T(ctx, "evidence.failed_at", "Stage", i18n.T(ctx, "evidence.stage_"+v.FailedAt)) } }
}{ i18n.T(ctx, "evidence.body_binary") }
} else if v.Body == "" {{ i18n.T(ctx, "evidence.body_empty") }
} else {{ v.ContentType } if v.Truncated { { " · " + i18n.T(ctx, "evidence.body_truncated") } }
{ v.Body }
}