mirror of
https://gitee.com/johng/gf
synced 2026-07-03 11:51:04 +08:00
fix comment issue in example codes for gmap
This commit is contained in:
@ -9,7 +9,7 @@ import (
|
||||
func main() {
|
||||
// 创建一个默认的gmap对象,
|
||||
// 默认情况下该gmap对象不支持并发安全特性,
|
||||
// 初始化时可以给定true参数关闭并发安全特性,当做一个普通的map使用。
|
||||
// 初始化时可以给定true参数开启并发安全特性,用以并发安全场景。
|
||||
m := gmap.New()
|
||||
|
||||
// 设置键值对
|
||||
|
||||
@ -1,10 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/text/gstr"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/net/ghttp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(gstr.CamelCase("/auth/routerName.html"))
|
||||
s := g.Server()
|
||||
s.SetIndexFolder(true)
|
||||
s.BindHandler("/admin.html", func(r *ghttp.Request) {
|
||||
r.Response.Write("admin")
|
||||
})
|
||||
s.BindHandler("/admin-do-{page}.html", func(r *ghttp.Request) {
|
||||
r.Response.Write("admin-do-" + r.GetString("page"))
|
||||
})
|
||||
s.SetPort(8999)
|
||||
s.Run()
|
||||
}
|
||||
|
||||
39
net/ghttp/ghttp_unit_mess_test.go
Normal file
39
net/ghttp/ghttp_unit_mess_test.go
Normal file
@ -0,0 +1,39 @@
|
||||
// Copyright 2018 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package ghttp_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/net/ghttp"
|
||||
"github.com/gogf/gf/test/gtest"
|
||||
)
|
||||
|
||||
func Test_GetUrl(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/url", func(r *ghttp.Request) {
|
||||
r.Response.Write(r.GetUrl())
|
||||
})
|
||||
s.SetPort(p)
|
||||
s.SetDumpRouteMap(false)
|
||||
s.Start()
|
||||
defer s.Shutdown()
|
||||
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
gtest.Case(t, func() {
|
||||
prefix := fmt.Sprintf("http://127.0.0.1:%d", p)
|
||||
client := ghttp.NewClient()
|
||||
client.SetBrowserMode(true)
|
||||
client.SetPrefix(prefix)
|
||||
|
||||
gtest.Assert(client.GetContent("/url"), prefix+"/url")
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user