switch urlStringVar {
case "/":
fmt.Println("ViewAllPosts")
case "/events":
fmt.Println("ViewEvents")
case "/about":
fmt.Println("ViewAbout")
case "/blog/{URLTitle}":
fmt.Println("ViewPost")
}
The detail (if possible) is that it must match exactly the same as it would with “gorilla/mux”, is there any way to achieve this? or what other option do you recommend?
You can extract parts (wildcards) of the url path in 2 levels down (in this example) using this function. This may need extra code to be fully functional.
Another option would be to check out the code for julienschmidt/httprouter. It is only a router, and has far fewer lines of code than gorilla/mux. Might be easier to understand the salient bits.