Golang with a jet router?

How to put routes in Go?

For example, I did

In Go:

Echo.Get("/*", *handler which return page with ReactRouter*)

React Router:

React.render((
<Router history={History.createHistory()}>
    <Route name="index" path="/" component={Main}>
        <Route name="users" path="/users" component={Users}>
            <Route name="user" path="/user/:userId" component={User} />
        </Route>
        <Route path="*" component={NotFound} />
    </Route>
</Router>
), document.body)

But I keep getting the index (/) page. All routes behave the same ("/", "/ users", "/ user / qwe", etc.)

+4
source share
1 answer

You must display different routes using new bindings or process this binding specifically in your handler function and read information about the request object.

Echo.Get("/user/:id", getUser)
Echo.Get("/users", listUsers)
Echo.Get("/*", catchAllRemainingCalls)

Hope this helps. Good luck

+2
source

Source: https://habr.com/ru/post/1607198/


All Articles