(configPath string, keys []string)
| 161 | } |
| 162 | |
| 163 | func warningPageHTML(configPath string, keys []string) string { |
| 164 | var b strings.Builder |
| 165 | b.WriteString(`<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Example API key detected</title><style>body{margin:0;font-family:Arial,sans-serif;background:#f6f8fa;color:#1f2328}.wrap{max-width:760px;margin:12vh auto;padding:0 24px}.panel{background:#fff;border:1px solid #d0d7de;border-radius:8px;padding:28px;box-shadow:0 8px 24px rgba(140,149,159,.2)}h1{margin:0 0 12px;font-size:28px;line-height:1.25}p{font-size:16px;line-height:1.55}code{background:#f6f8fa;border:1px solid #d0d7de;border-radius:4px;padding:2px 5px}.keys{margin:16px 0;padding-left:22px}.path{word-break:break-all}</style></head><body><main class="wrap"><section class="panel"><h1>Example API key detected</h1><p>The normal API server was not started because the top-level <code>api-keys</code> configuration still contains template values.</p>`) |
| 166 | if len(keys) > 0 { |
| 167 | b.WriteString(`<p>Replace these values before using the proxy:</p><ul class="keys">`) |
| 168 | for _, key := range keys { |
| 169 | b.WriteString(`<li><code>`) |
| 170 | b.WriteString(html.EscapeString(key)) |
| 171 | b.WriteString(`</code></li>`) |
| 172 | } |
| 173 | b.WriteString(`</ul>`) |
| 174 | } |
| 175 | if strings.TrimSpace(configPath) != "" { |
| 176 | b.WriteString(`<p>Edit <code class="path">`) |
| 177 | b.WriteString(html.EscapeString(configPath)) |
| 178 | b.WriteString(`</code>, set strong random API keys, then restart CLIProxyAPI.</p>`) |
| 179 | } else { |
| 180 | b.WriteString(`<p>Edit your config file, set strong random API keys, then restart CLIProxyAPI.</p>`) |
| 181 | } |
| 182 | b.WriteString(`</section></main></body></html>`) |
| 183 | return b.String() |
| 184 | } |
no test coverage detected