Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetLimit ¶ added in v0.0.5
Example ¶
package main
import (
"fmt"
"net/http/httptest"
"github.com/gin-gonic/gin"
"github.com/itsubaki/fourkeys/handler"
)
func main() {
gin.SetMode(gin.ReleaseMode)
req := httptest.NewRequest("GET", "/_test?limit=999", nil)
c, _ := gin.CreateTestContext(httptest.NewRecorder())
c.Request = req
handler.SetLimit(c)
fmt.Println(c.GetString("limit"))
}
Output: 999
func SetTraceID ¶
Example ¶
package main
import (
"fmt"
"math/rand"
"net/http/httptest"
"github.com/gin-gonic/gin"
"github.com/itsubaki/fourkeys/handler"
)
func main() {
gin.SetMode(gin.ReleaseMode)
req := httptest.NewRequest("GET", "/", nil)
value := fmt.Sprintf("%016x%016x/%d;o=1", rand.Int63(), rand.Int63(), rand.Int63())
req.Header.Add("X-Cloud-Trace-Context", value)
c, _ := gin.CreateTestContext(httptest.NewRecorder())
c.Request = req
handler.SetTraceID(c)
fmt.Println(c.GetBool("trace_true"))
}
Output: true
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.