Ai
70 Star 93 Fork 79

openEuler/PilotGo-plugins

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
handler.go 612 Bytes
Copy Edit Raw Blame History
guozhengxin1999 authored 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

Search