redirect test

This commit is contained in:
CarOL 2023-08-18 23:10:27 +08:00
parent e9cc302168
commit fbf6b8e1f3
3 changed files with 17 additions and 7 deletions

View file

@ -5,6 +5,7 @@ import (
"io"
"net/http"
"regexp"
"strings"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
@ -44,7 +45,11 @@ func fetch(url string, pattern string) (string, error) {
fmt.Println("Target URL not found")
return DEFAULT_URL, nil
}
return matched[0][1], nil
target := matched[0][1]
target = strings.Replace(target, "m.html", "images/end.jpg", 1)
target = strings.Replace(target, "index.html", "images/end.jpg", 1)
return target, nil
}
func handler(request events.APIGatewayProxyRequest) (*events.APIGatewayProxyResponse, error) {

View file

@ -12,21 +12,22 @@ export default {
name: "App",
data() {
return {
api_endpoint: 'https://9966df427a59473692f15d799442f2ce.apig.ap-southeast-3.huaweicloudapis.com/qndxx',
api_endpoint: window.location.href + '/.netlify/functions/qndxx',
title: "正在请求数据...",
dxx: '正在获取图片...'
result: '正在获取图片...'
};
},
mounted() {
axios
.get(this.api_endpoint)
.then((resp) => {
this.title = resp.data.title
this.dxx = resp.data.dxx_img
this.result = resp.data.result
window.location.replace(this.result)
})
.catch((err) => {
console.log(err)
window.location.replace('https://google.com')
this.result = resp.data.result
window.location.replace(this.result)
})
},
metaInfo() {

View file

@ -5,6 +5,7 @@ import (
"io"
"net/http"
"regexp"
"strings"
)
const default_url = "https://b23.tv/BV1uT4y1P7CX"
@ -32,7 +33,10 @@ func fetch(url string, pattern string) string {
fmt.Println("Target URL not found")
return default_url
}
return matched[0][1] // first match, first group
target := matched[0][1]
target = strings.Replace(target, "m.html", "images/end.jpg", 1)
target = strings.Replace(target, "index.html", "images/end.jpg", 1)
return target
}
func main() {