Routing in separate "package router"


#1

Hello!
I’m new to Golang.
For several weeks I played with the Echo framework and faced the problem that I just can’t figure out how to use routing anywhere other than the entry point (server.go or main.go) and the root function main.
Tell me, is there a way to use routing somewhere else? For example, in a separate package “router”.
Using all the routing in the main file seems a bit awkward and dirty. I would like to change that.
I would be grateful for the help!


#2

See if this works for you. Here is the directory structure of the code.
$$$ ls ./githubquestion
|—router/router.go (https://play.golang.org/p/CRkdM5SR5bc)
|—main.go (https://play.golang.org/p/Om_XeaZ0AyF)

All routing logic is in different package.
Initializing the echo context from main and passing the context to the function responsible for handling the routing logic.


#3

Keep sharing your valuable content.