Skip to content
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

[Promotion] Provide url style routing way, help tcpx practice better! #39

Open
fwhezfwhez opened this issue Oct 29, 2020 · 0 comments
Open
Labels
enhancement New feature or request promotion profile existing feature and provide better practise

Comments

@fwhezfwhez
Copy link
Owner

Hello!
Tcpx now provide a better practice routing style for developer. In the past, routers are like:

srv.AddHandler(1, login)
srv.AddHandler(3, auth)

This kind of routing is based on messageID. It seems easy but require developers to manage all messageID themselves, it's really a tiring job.

But now ,tcpx provides better routing style, it will gradually replace the old messageID routing.(But will not abandon usage of messageID and still keep compatible of old stf). It works like:

srv.Any("/login/", login)
srv.Any("/auth/", auth)

Also, when server side wants to reply:

func login(c *tcpx.Context) {
    c.JSONURLPattern(map[string]interface{}{
        "message": "login success, welcome!"
    })
}

More usages of url-pattern routing, you may refer to

@fwhezfwhez fwhezfwhez added promotion profile existing feature and provide better practise enhancement New feature or request labels Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request promotion profile existing feature and provide better practise
Projects
None yet
Development

No branches or pull requests

1 participant