StoreBackEnd/pkg/protocol/managers/RequestManager.go

29 lines
591 B
Go
Raw Normal View History

package managers
import (
"StoreBackEnd/pkg/protocol/repository"
"net"
)
type RequestManager struct {
2022-02-22 08:29:11 +01:00
Repository *repository.ProtocolRepository
}
func (receiver RequestManager) Execute(request string, reader net.Conn) string {
// On lis ce que l'on reçoit
result, executed, readCb := receiver.Repository.ExecuteReader(request)
// On renvoie la réponse (Comment pour fichier ?)
if executed {
if readCb != nil {
cbResult, _ := readCb(reader)
if cbResult != "" {
result = cbResult
}
}
return result
} else {
return "Error occurred while execute command"
}
}