-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathhandler_noop.go
29 lines (23 loc) · 913 Bytes
/
handler_noop.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package smtpmock
// NOOP command handler
type handlerNoop struct {
*handler
}
// NOOP command handler builder. Returns pointer to new handlerNoop structure
func newHandlerNoop(session sessionInterface, message *Message, configuration *configuration) *handlerNoop {
return &handlerNoop{&handler{session: session, message: message, configuration: configuration}}
}
// NOOP handler methods
// Main NOOP handler runner
func (handler *handlerNoop) run(request string) {
if handler.isInvalidRequest(request) {
return
}
handler.message.noop = true
configuration := handler.configuration
handler.session.writeResponse(configuration.msgNoopReceived, configuration.responseDelayNoop)
}
// Invalid NOOP command predicate. Returns true when request is invalid, otherwise returns false
func (handler *handlerNoop) isInvalidRequest(request string) bool {
return !matchRegex(request, validNoopCmdRegexPattern)
}