aws_transaction.go 670 B

123456789101112131415161718192021222324
  1. package service
  2. import (
  3. "net/http"
  4. "github.com/gin-gonic/gin"
  5. "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_daemon/backwards_invocation/transaction"
  6. "github.com/langgenius/dify-plugin-daemon/internal/core/session_manager"
  7. )
  8. func HandleAWSPluginTransaction(handler *transaction.AWSTransactionHandler) gin.HandlerFunc {
  9. return func(c *gin.Context) {
  10. // get session id from the context
  11. session_id := c.Request.Header.Get("Dify-Plugin-Session-ID")
  12. session := session_manager.GetSession(session_id)
  13. if session == nil {
  14. c.JSON(http.StatusBadRequest, gin.H{"error": "session not found"})
  15. return
  16. }
  17. handler.Handle(c, session_id)
  18. }
  19. }