草庐IT

redirectApiPoint

全部标签

正则表达式在 Golang HandleFunc 函数中不起作用

我正在尝试根据Go中的模式重定向URL。如果我的URL包含“clientApi”,那么我将它发送到clientApiPointfunc,否则我将它发送到redirectApiPointfunc。我的handleRequest函数是funchandleRequest(){r:=mux.NewRouter()r.HandleFunc("/",homePage)r.HandleFunc("/clientApi",clientApiPoint)r.HandleFunc("/{^((?!clientApi).)*$}",redirectApiPoint)http.Handle("/",r)log