2021-07-18 15:51:49 +08:00
|
|
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
|
|
|
|
|
|
|
|
|
package waf
|
|
|
|
|
|
2021-10-18 20:08:43 +08:00
|
|
|
import (
|
|
|
|
|
"net/http"
|
|
|
|
|
)
|
|
|
|
|
|
2021-07-18 15:51:49 +08:00
|
|
|
type BaseAction struct {
|
2022-05-21 11:17:53 +08:00
|
|
|
currentActionId int64
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ActionId 读取ActionId
|
|
|
|
|
func (this *BaseAction) ActionId() int64 {
|
|
|
|
|
return this.currentActionId
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SetActionId 设置Id
|
|
|
|
|
func (this *BaseAction) SetActionId(actionId int64) {
|
|
|
|
|
this.currentActionId = actionId
|
2021-07-18 15:51:49 +08:00
|
|
|
}
|
2021-10-18 20:08:43 +08:00
|
|
|
|
|
|
|
|
// CloseConn 关闭连接
|
|
|
|
|
func (this *BaseAction) CloseConn(writer http.ResponseWriter) error {
|
|
|
|
|
// 断开连接
|
|
|
|
|
hijack, ok := writer.(http.Hijacker)
|
|
|
|
|
if ok {
|
|
|
|
|
conn, _, err := hijack.Hijack()
|
2021-10-25 19:42:12 +08:00
|
|
|
if err == nil && conn != nil {
|
2021-10-18 20:08:43 +08:00
|
|
|
return conn.Close()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|