mirror of
https://gitee.com/chuangxxt/share-copilot
synced 2025-04-16 10:13:26 +00:00
20239/12 16:11
This commit is contained in:
parent
5ac6b5863a
commit
dafdf2f72e
86
src/test.go
Normal file
86
src/test.go
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
func getGithubTest(c *gin.Context, token string) {
|
||||||
|
githubApiCount++
|
||||||
|
data1 := `
|
||||||
|
{
|
||||||
|
"chat_enabled": false,
|
||||||
|
"code_quote_enabled": false,
|
||||||
|
"code_quote_v2_enabled": false,
|
||||||
|
"copilotignore_enabled": false,
|
||||||
|
"expires_at": 3194360727,
|
||||||
|
"prompt_8k": true,
|
||||||
|
"public_suggestions": "disabled",
|
||||||
|
"refresh_in": 1500,
|
||||||
|
"sku": "free_educational",
|
||||||
|
"telemetry": "disabled",
|
||||||
|
"token": "tid=;exp=1694360727;sku=free_educational;st=dotcom;8kp=1:",
|
||||||
|
"tracking_id": ""
|
||||||
|
}
|
||||||
|
`
|
||||||
|
data2 := `
|
||||||
|
{
|
||||||
|
"chat_enabled": false,
|
||||||
|
"code_quote_enabled": false,
|
||||||
|
"code_quote_v2_enabled": false,
|
||||||
|
"copilotignore_enabled": false,
|
||||||
|
"expires_at": 2294360727,
|
||||||
|
"prompt_8k": true,
|
||||||
|
"public_suggestions": "disabled",
|
||||||
|
"refresh_in": 1500,
|
||||||
|
"sku": "free_educational",
|
||||||
|
"telemetry": "disabled",
|
||||||
|
"token": "tid=;exp=1694360727;sku=free_educational;st=dotcom;8kp=1:",
|
||||||
|
"tracking_id": ""
|
||||||
|
}
|
||||||
|
`
|
||||||
|
data3 := `
|
||||||
|
{
|
||||||
|
"chat_enabled": false,
|
||||||
|
"code_quote_enabled": false,
|
||||||
|
"code_quote_v2_enabled": false,
|
||||||
|
"copilotignore_enabled": false,
|
||||||
|
"expires_at": 3394360727,
|
||||||
|
"prompt_8k": true,
|
||||||
|
"public_suggestions": "disabled",
|
||||||
|
"refresh_in": 1500,
|
||||||
|
"sku": "free_educational",
|
||||||
|
"telemetry": "disabled",
|
||||||
|
"token": "tid=;exp=1694360727;sku=free_educational;st=dotcom;8kp=1:",
|
||||||
|
"tracking_id": ""
|
||||||
|
}
|
||||||
|
`
|
||||||
|
//响应体map
|
||||||
|
var respDataMap = make(map[string]interface{})
|
||||||
|
if token == "1" {
|
||||||
|
err := json.Unmarshal([]byte(data1), &respDataMap)
|
||||||
|
if err != nil {
|
||||||
|
// 处理JSON解析错误
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "JSON parsing error"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else if token == "2" {
|
||||||
|
err := json.Unmarshal([]byte(data2), &respDataMap)
|
||||||
|
if err != nil {
|
||||||
|
// 处理JSON解析错误
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "JSON parsing error"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
err := json.Unmarshal([]byte(data3), &respDataMap)
|
||||||
|
if err != nil {
|
||||||
|
// 处理JSON解析错误
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "JSON parsing error"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//token map
|
||||||
|
tokenMap[token] = respDataMap
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user