Files
EdgeNode/internal/waf/action_base.go

35 lines
649 B
Go
Raw Normal View History

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 {
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
}