I am trying to redirect the URL based on a pattern in Go. If my URL is containing "clientApi" then I am sending it to clientApiPoint func otherwise I am sending it to redirectApiPoint func. My handleRequest func is
func handleRequest() {
r := mux.NewRouter()
r.HandleFunc("/", homePage)
r.HandleFunc("/clientApi", clientApiPoint)
r.HandleFunc("/{^((?!clientApi).)*$}", redirectApiPoint)
http.Handle("/", r)
log.Fatal(http.ListenAndServe(":8081", nil))
}
{^((?!clientApi).)*$} regex is working fine if my url is something like
localhost:8081/somerandonurl (sending it to redirectApiPoint func)
but if there one or more "/" in the url, regex is not redirecting it to redirectApiPoint func.
localhost:8081/somerandonurl/somethingdifferent (not sending it to redirectApiPoint. 404 page not found message)