Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
apaas-meshproxy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gzga-jzapi
apaas-meshproxy
Commits
7c8ab5bd
Commit
7c8ab5bd
authored
May 31, 2022
by
李科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
申请使用期限时间逻辑判断
parent
f45a56d2
Pipeline
#77800
passed with stage
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
7 deletions
+21
-7
.beagle.yml
.beagle.yml
+3
-3
go.mod
go.mod
+1
-0
go.sum
go.sum
+6
-1
src/handler/proxyhandler.go
src/handler/proxyhandler.go
+11
-3
No files found.
.beagle.yml
View file @
7c8ab5bd
...
...
@@ -50,7 +50,7 @@ steps:
base
:
registry.cn-qingdao.aliyuncs.com/wod/alpine-glibc:3.12
dockerfile
:
.beagle/dockerfile
repo
:
gzgajzapi/apaas-meshproxy
Version
:
"
v3.0.
6
"
Version
:
"
v3.0.
7
"
channel
:
alpha
args
:
"
TARGETOS=linux,TARGETARCH=amd64"
registry
:
hub.wodcloud.com
...
...
@@ -87,8 +87,8 @@ steps:
REGISTRY_PASSWORD
:
from_secret
:
REGISTRY_PASSWORD
settings
:
source
:
hub.wodcloud.com/gzgajzapi/apaas-meshproxy:v3.0.
6
-alpha
target
:
hub.wodcloud.com/gzgajzapi/apaas-meshproxy:v3.0.
6
source
:
hub.wodcloud.com/gzgajzapi/apaas-meshproxy:v3.0.
7
-alpha
target
:
hub.wodcloud.com/gzgajzapi/apaas-meshproxy:v3.0.
7
registry
:
hub.wodcloud.com
---
...
...
go.mod
View file @
7c8ab5bd
...
...
@@ -8,6 +8,7 @@ require (
github.com/gin-gonic/gin v1.6.3
github.com/go-redis/redis v6.15.9+incompatible
github.com/go-sql-driver/mysql v1.6.0
github.com/golang-module/carbon/v2 v2.1.8
github.com/lib/pq v1.10.0
github.com/natefinch/lumberjack v2.0.0+incompatible
github.com/sirupsen/logrus v1.8.1
...
...
go.sum
View file @
7c8ab5bd
...
...
@@ -46,6 +46,8 @@ github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8w
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/golang-module/carbon/v2 v2.1.8 h1:pBBmSuLjeXZPzRwGqmZE97wyg6EnEqkFFEq6tlmGwHA=
github.com/golang-module/carbon/v2 v2.1.8/go.mod h1:NF5unWf838+pyRY0o+qZdIwBMkFf7w0hmLIguLiEpzU=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
...
...
@@ -122,8 +124,9 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE=
...
...
@@ -207,4 +210,6 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
launchpad.net/gocheck v0.0.0-20140225173054-000000000087/go.mod h1:hj7XX3B/0A+80Vse0e+BUHsHMTEhd0O4cpUHr/e/BUM=
src/handler/proxyhandler.go
View file @
7c8ab5bd
...
...
@@ -7,6 +7,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/golang-module/carbon/v2"
"io/ioutil"
"log"
"net/http"
...
...
@@ -76,14 +77,17 @@ func Proxy(c *gin.Context) {
c
.
JSON
(
200
,
res
)
return
}
nowTime
:=
time
.
Now
()
.
Format
(
"2006-01-02"
)
if
proxyData
.
RequestStartTime
>
nowTime
{
requestStartTime
:=
FormatDateToCarbon
(
proxyData
.
RequestStartTime
)
requestEndTime
:=
FormatDateToCarbon
(
proxyData
.
RequestEndTime
)
now
:=
carbon
.
Now
(
carbon
.
Shanghai
)
if
requestStartTime
.
Gt
(
now
)
{
res
:=
model
.
WebRes
{}
res
.
ErrMsg
=
`申请使用期限未开始`
c
.
JSON
(
200
,
res
)
return
}
if
proxyData
.
RequestEndTime
<
nowTime
{
if
requestEndTime
.
Lt
(
now
)
{
res
:=
model
.
WebRes
{}
res
.
ErrMsg
=
`申请使用期限已过期`
c
.
JSON
(
200
,
res
)
...
...
@@ -256,6 +260,10 @@ func Proxy(c *gin.Context) {
}
func
FormatDateToCarbon
(
date
string
)
carbon
.
Carbon
{
return
carbon
.
Parse
(
strings
.
Replace
(
strings
.
TrimRight
(
strings
.
TrimSpace
(
date
),
"Z"
),
"T"
,
" "
,
-
1
),
carbon
.
Shanghai
)
}
func
CheckStaticFile
(
path
string
)
bool
{
if
strings
.
HasSuffix
(
path
,
".css"
)
||
strings
.
HasSuffix
(
path
,
".js"
)
||
strings
.
HasSuffix
(
path
,
".woff2"
)
||
strings
.
HasSuffix
(
path
,
".jpg"
)
||
strings
.
HasSuffix
(
path
,
".svg"
)
||
strings
.
HasSuffix
(
path
,
".woff"
)
||
strings
.
HasSuffix
(
path
,
".html"
)
||
strings
.
HasSuffix
(
path
,
".ttf"
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment