Commit ce03c31b by huangchengyi

test

parent 4edd7d85
Showing with 9 additions and 4 deletions
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.Microsecond),
timeout.WithTimeout(2*time.Second),
timeout.WithHandler(emptySuccessResponse),
timeout.WithResponse(errorResponse),
))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment