Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
search_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ce03c31b
authored
Dec 24, 2020
by
huangchengyi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
test
parent
4edd7d85
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
doc/test/time1.go
doc/test/time1.go
View file @
ce03c31b
package
main
import
(
"github.com/syyongx/php2go"
"net/http"
"time"
...
...
@@ -9,9 +10,13 @@ import (
)
func
emptySuccessResponse
(
c
*
gin
.
Context
)
{
i
:=
2
time
.
Sleep
(
i
*
time
.
Second
)
c
.
String
(
http
.
StatusOK
,
""
)
if
php2go
.
Rand
(
1
,
2
)
==
1
{
time
.
Sleep
(
1
*
time
.
Second
)
}
else
{
time
.
Sleep
(
2
*
time
.
Second
)
}
c
.
String
(
http
.
StatusOK
,
"成功-往下走"
)
}
func
errorResponse
(
c
*
gin
.
Context
)
{
c
.
String
(
http
.
StatusRequestTimeout
,
"超时"
)
...
...
@@ -21,7 +26,7 @@ func main() {
r
:=
gin
.
New
()
r
.
GET
(
"/"
,
timeout
.
New
(
timeout
.
WithTimeout
(
100
*
time
.
Micros
econd
),
timeout
.
WithTimeout
(
2
*
time
.
S
econd
),
timeout
.
WithHandler
(
emptySuccessResponse
),
timeout
.
WithResponse
(
errorResponse
),
))
...
...
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