30 lines
617 B
Go
30 lines
617 B
Go
package managers
|
|
|
|
import (
|
|
"StoreBackEnd/pkg/protocol"
|
|
"StoreBackEnd/pkg/protocol/repository"
|
|
"bufio"
|
|
)
|
|
|
|
type RequestManager struct {
|
|
Repository *repository.ProtocolRepository
|
|
}
|
|
|
|
func (receiver RequestManager) Execute(request string, reader *bufio.Reader) *protocol.ProtocolWriterResult {
|
|
// On lis ce que l'on reçoit
|
|
writeCmd, readCb := receiver.Repository.ExecuteReader(request)
|
|
|
|
// On renvoie la réponse (Comment pour fichier ?)
|
|
if writeCmd != nil {
|
|
if readCb != nil {
|
|
cbResult := readCb(reader)
|
|
if cbResult != nil {
|
|
writeCmd = cbResult
|
|
}
|
|
}
|
|
return writeCmd
|
|
} else {
|
|
return nil
|
|
}
|
|
}
|