30 lines
646 B
Go
30 lines
646 B
Go
package managers
|
|
|
|
import (
|
|
"StoreBackEnd/pkg/protocol/repository"
|
|
"bufio"
|
|
)
|
|
|
|
type RequestManager struct {
|
|
Repository *repository.ProtocolRepository
|
|
}
|
|
|
|
func (receiver RequestManager) Execute(request string, reader *bufio.Reader) 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 {
|
|
// TODO : Renvoyer qu'une erreur est survenue
|
|
return "Error occurred while execute command"
|
|
}
|
|
}
|