github.com/zhongdalu/gf@v1.0.0/g/net/ghttp/ghttp_request_router.go (about) 1 // Copyright 2017 gf Author(https://github.com/zhongdalu/gf). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/zhongdalu/gf. 6 7 package ghttp 8 9 func (r *Request) SetRouterString(key, value string) { 10 r.routerVars[key] = []string{value} 11 } 12 13 func (r *Request) AddRouterString(key, value string) { 14 r.routerVars[key] = append(r.routerVars[key], value) 15 } 16 17 // 获得路由解析参数 18 func (r *Request) GetRouterString(key string) string { 19 if v := r.GetRouterArray(key); v != nil { 20 return v[0] 21 } 22 return "" 23 } 24 25 // 获得路由解析参数 26 func (r *Request) GetRouterArray(key string) []string { 27 if v, ok := r.routerVars[key]; ok { 28 return v 29 } 30 return nil 31 }