-
Notifications
You must be signed in to change notification settings - Fork 5
Refactor handlers #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- move handlers into separate files - use interfaces for handlers, etc - update README.md files
Machan, how about this one. Then testing and everything will be simple. type MessageHandle func(*Server, Response, Message) error
// These are the handles
func connectHandle(s *Server, res Response, m Message) error {
return res.WriteJSON(map[string]string{
"msg": "connected",
"session": random.Id(17),
})
}
func pingHandle(s *Server, res Response, m Message) error {
...
}
func methodHandle(s *Server, res Response, m Message) error {
...
}
DDPHandlers:= map[string]MessageHandle {
"connect": connectHandle,
"ping": pingHandle,
"method": methodHandle
}
// In the server.
if handler, ok := DDPHandlers[msg.Msg]; ok {
go handler(s, res, msg)
} else {
break
} |
Yeah. Code is a lot simpler this way. On Wed, Feb 18, 2015, 20:48 Arunoda Susiripala notifications@github.com
|
great. On Wed Feb 18 2015 at 9:18:03 PM Muhammed Thanish notifications@github.com
|
Added some integration tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate.
b51ae7e
to
535d079
Compare
No description provided.