mirror of
https://github.com/langgenius/dify.git
synced 2026-05-03 08:58:09 +08:00
feat(trigger): add trigger provider management and webhook handling functionality
This commit is contained in:
@ -4,4 +4,4 @@ from flask import Blueprint
|
||||
bp = Blueprint("trigger", __name__, url_prefix="/triggers")
|
||||
|
||||
# Import routes after blueprint creation to avoid circular imports
|
||||
from . import webhook
|
||||
from . import trigger, webhook
|
||||
|
||||
23
api/controllers/trigger/trigger.py
Normal file
23
api/controllers/trigger/trigger.py
Normal file
@ -0,0 +1,23 @@
|
||||
import logging
|
||||
|
||||
from flask import jsonify, request
|
||||
from werkzeug.exceptions import NotFound
|
||||
|
||||
from controllers.trigger import bp
|
||||
from services.trigger_service import TriggerService
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@bp.route("/trigger/webhook/<string:endpoint_id>", methods=["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"])
|
||||
def trigger_webhook(endpoint_id: str):
|
||||
"""
|
||||
Handle webhook trigger calls.
|
||||
"""
|
||||
try:
|
||||
return TriggerService.process_webhook(endpoint_id, request)
|
||||
except ValueError as e:
|
||||
raise NotFound(str(e))
|
||||
except Exception as e:
|
||||
logger.exception("Webhook processing failed for {endpoint_id}")
|
||||
return jsonify({"error": "Internal server error", "message": str(e)}), 500
|
||||
Reference in New Issue
Block a user