feat(swagger): add Swagger UI for API documentation
* 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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user