mirror of
https://github.com/wonli/aqi.git
synced 2025-12-24 10:40:58 +08:00
refactor: simplify nil check and fix handler validation
- Simplify IsNil() method by directly returning the nil check result - Remove redundant nil check for handlers slice and fix indentation
This commit is contained in:
@@ -33,11 +33,7 @@ func (v *Value) Raw() any {
|
||||
}
|
||||
|
||||
func (v *Value) IsNil() bool {
|
||||
if v.data == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
return v.data == nil
|
||||
}
|
||||
|
||||
func (v *Value) String() string {
|
||||
|
||||
@@ -43,11 +43,11 @@ func Dispatcher(c *Client, request string) {
|
||||
c.LastHeartbeatTime = t
|
||||
}
|
||||
|
||||
handlers := InitManager().Handlers(req.Action)
|
||||
if handlers == nil || len(handlers) == 0 {
|
||||
c.SendActionMsg(&Action{Action: req.Action, Code: -1005, Msg: "request not supported"})
|
||||
return
|
||||
}
|
||||
handlers := InitManager().Handlers(req.Action)
|
||||
if len(handlers) == 0 {
|
||||
c.SendActionMsg(&Action{Action: req.Action, Code: -1005, Msg: "request not supported"})
|
||||
return
|
||||
}
|
||||
|
||||
ctx := &Context{
|
||||
Id: req.Id,
|
||||
|
||||
Reference in New Issue
Block a user