feat(swagger): add Swagger UI for API documentation
Some checks failed
CI / Test (1.23) (push) Failing after -20m40s
CI / Test (1.22) (push) Failing after -20m58s
CI / Build (push) Failing after -21m33s
CI / Lint (push) Failing after -20m51s

* Create index.html for Swagger UI integration
* Link to Swagger UI CSS and JS from CDN
* Configure Swagger UI to load API specification from api.json
This commit is contained in:
Hein
2026-02-20 17:41:20 +02:00
parent 5b3aaba198
commit a3ff2dc497
7 changed files with 3516 additions and 319 deletions

View File

@@ -390,7 +390,11 @@ func (m *Manager) sendToHook(ctx context.Context, hook config.Hook, payload inte
}
parsedURL.RawQuery = query.Encode()
req, err := http.NewRequestWithContext(hookCtx, hook.Method, parsedURL.String(), bytes.NewReader(data))
method := hook.Method
if method == "" {
method = http.MethodPost
}
req, err := http.NewRequestWithContext(hookCtx, method, parsedURL.String(), bytes.NewReader(data))
if err != nil {
logging.Error("Failed to create request", "hook_id", hook.ID, "error", err)
m.eventBus.Publish(events.HookFailedEvent(eventCtx, hook.ID, hook.Name, err))
@@ -413,8 +417,14 @@ func (m *Manager) sendToHook(ctx context.Context, hook config.Hook, payload inte
defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
logging.Warn("Hook returned non-success status", "hook_id", hook.ID, "status", resp.StatusCode)
m.eventBus.Publish(events.HookFailedEvent(eventCtx, hook.ID, hook.Name, fmt.Errorf("status code %d", resp.StatusCode)))
errBody, _ := io.ReadAll(resp.Body)
logging.Warn("Hook returned non-success status",
"hook_id", hook.ID,
"status", resp.StatusCode,
"status_text", resp.Status,
"body", string(errBody),
)
m.eventBus.Publish(events.HookFailedEvent(eventCtx, hook.ID, hook.Name, fmt.Errorf("%s: %s", resp.Status, string(errBody))))
return nil
}