Ai
70 Star 93 Fork 79

openEuler/PilotGo-plugins

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
handler.go 612 Bytes
一键复制 编辑 原始数据 按行查看 历史
guozhengxin1999 提交于 2023-06-06 11:42 +08:00 . refactory client sdk code
package client
import (
"fmt"
"net/http"
"net/http/httputil"
"net/url"
"strings"
"github.com/gin-gonic/gin"
)
func ReverseProxyHandler(c *gin.Context) {
remote := c.GetString("__internal__reverse_dest")
if remote == "" {
fmt.Println("get reverse dest failed!")
return
}
target, err := url.Parse(remote)
if err != nil {
return
}
proxy := httputil.NewSingleHostReverseProxy(target)
c.Request.URL.Path = strings.Replace(c.Request.URL.Path, "/plugin/grafana", "", 1) //请求API
proxy.ServeHTTP(c.Writer, c.Request)
}
func InfoHandler(c *gin.Context) {
c.JSON(http.StatusOK, BaseInfo)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openeuler/PilotGo-plugins.git
git@gitee.com:openeuler/PilotGo-plugins.git
openeuler
PilotGo-plugins
PilotGo-plugins
80198980aca1

搜索帮助