|
@@ -6,6 +6,7 @@ import (
|
|
"git.sxidc.com/service-supports/fserr"
|
|
"git.sxidc.com/service-supports/fserr"
|
|
"git.sxidc.com/service-supports/fslog"
|
|
"git.sxidc.com/service-supports/fslog"
|
|
"git.sxidc.com/service-supports/websocket"
|
|
"git.sxidc.com/service-supports/websocket"
|
|
|
|
+ "net/http"
|
|
)
|
|
)
|
|
|
|
|
|
func SendMsgResponse(c *binding_context.Context, statusCode int, _ any, err error) {
|
|
func SendMsgResponse(c *binding_context.Context, statusCode int, _ any, err error) {
|
|
@@ -136,3 +137,29 @@ func WSSendMessage(groupID string, obj any) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func SendString(c *binding_context.Context, statusCode int, data string, err error) {
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.String(http.StatusOK, err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ c.String(http.StatusOK, data)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func WriteBytes(c *binding_context.Context, statusCode int, bytes []byte, err error) {
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.AbortWithStatus(statusCode)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ _, err = c.Writer.Write(bytes)
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.AbortWithStatus(statusCode)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func SendMapXMLResponseIgnoreError(c *binding_context.Context, statusCode int, data map[string]any, _ error) {
|
|
|
|
+ c.XML(statusCode, data)
|
|
|
|
+}
|