RegexMatcher.go :
- Suppression HelloRule.go qui n'était pas adaptée - Création EraseFileRule.go et implémentation de son interface IProtocol.go - Rename méthode RegexMatcher.go match -> Match
This commit is contained in:
parent
6f097e6642
commit
4c368ef551
@ -1,6 +1,8 @@
|
||||
package main
|
||||
|
||||
import "_StorBackEnd/pkg/network"
|
||||
import (
|
||||
"_StorBackEnd/pkg/network"
|
||||
)
|
||||
|
||||
const (
|
||||
MULTICAST_ADDRESS = "226.0.0.1:42500"
|
||||
|
@ -17,7 +17,7 @@ type RegexMatcher struct {
|
||||
matcher *regexp.Regexp
|
||||
}
|
||||
|
||||
// match Permet de vérifier la validité d'une donnée affiliée à un protocole
|
||||
func (m RegexMatcher) match(data string) bool {
|
||||
// Match Permet de vérifier la validité d'une donnée affiliée à un protocole
|
||||
func (m RegexMatcher) Match(data string) bool {
|
||||
return m.matcher.MatchString(data)
|
||||
}
|
||||
|
31
pkg/protocol/rules/EraseFileRule.go
Normal file
31
pkg/protocol/rules/EraseFileRule.go
Normal file
@ -0,0 +1,31 @@
|
||||
package rules
|
||||
|
||||
import "_StorBackEnd/pkg/protocol"
|
||||
|
||||
// EraseFileRule Demande de suppression d'un fichier
|
||||
type EraseFileRule struct {
|
||||
protocol.IProtocol
|
||||
// Cmd Nom de la règle
|
||||
Cmd string
|
||||
|
||||
// matcher Permet de vérifier le matching
|
||||
matcher *protocol.RegexMatcher
|
||||
}
|
||||
|
||||
// CreateEraseFileRule Création d'une instance de EraseFileRule
|
||||
func CreateEraseFileRule(cmd string, pattern string) *EraseFileRule {
|
||||
return &EraseFileRule{
|
||||
Cmd: cmd,
|
||||
matcher: protocol.CreateRegexMatcher(pattern),
|
||||
}
|
||||
}
|
||||
|
||||
func (rule EraseFileRule) execute(data string) {
|
||||
matcher := rule.matcher
|
||||
|
||||
if matcher.Match(data) {
|
||||
println("EraseFileRule data is matching")
|
||||
} else {
|
||||
println("EraseFileRule data isn't matching")
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package rules
|
||||
|
||||
import "_StorBackEnd/pkg/protocol"
|
||||
|
||||
type HelloRule struct {
|
||||
cmd string
|
||||
matcher *protocol.RegexMatcher
|
||||
}
|
||||
|
||||
func Create(cmd string, pattern string) *HelloRule {
|
||||
h := new(HelloRule)
|
||||
h.cmd = cmd
|
||||
h.matcher = protocol.CreateRegexMatcher(pattern)
|
||||
|
||||
return h
|
||||
}
|
||||
|
||||
func (rule HelloRule) execute(data string) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
Loading…
Reference in New Issue
Block a user