Skip to content

Commit 0f492d1

Browse files
Dean KarnDean Karn
Dean Karn
authored and
Dean Karn
committed
unexposed Param + Params type
- it was not exposed nor able to be sed outside.
1 parent e948726 commit 0f492d1

File tree

5 files changed

+17
-21
lines changed

5 files changed

+17
-21
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
##Pure
22
<img align="right" src="https://raw.githubusercontent.com/go-playground/pure/master/logo.png">
3-
![Project status](https://img.shields.io/badge/version-3.1.0-green.svg)
3+
![Project status](https://img.shields.io/badge/version-3.1.1-green.svg)
44
[![Build Status](https://semaphoreci.com/api/v1/joeybloggs/pure/branches/master/badge.svg)](https://semaphoreci.com/joeybloggs/pure)
55
[![Coverage Status](https://coveralls.io/repos/github/go-playground/pure/badge.svg?branch=master)](https://coveralls.io/github/go-playground/pure?branch=master)
66
[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/pure)](https://goreportcard.com/report/github.com/go-playground/pure)

helpers.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func ParseForm(r *http.Request) error {
208208

209209
if !rv.formParsed {
210210
for _, p := range rv.params {
211-
r.Form.Add(p.Key, p.Value)
211+
r.Form.Add(p.key, p.value)
212212
}
213213

214214
rv.formParsed = true
@@ -234,7 +234,7 @@ func ParseMultipartForm(r *http.Request, maxMemory int64) error {
234234

235235
if !rv.formParsed {
236236
for _, p := range rv.params {
237-
r.Form.Add(p.Key, p.Value)
237+
r.Form.Add(p.key, p.value)
238238
}
239239

240240
rv.formParsed = true
@@ -396,7 +396,7 @@ func QueryParams(r *http.Request, includeSEOQueryParams bool) (values url.Values
396396
rv := rvi.(*requestVars)
397397

398398
for _, p := range rv.params {
399-
values.Add(p.Key, p.Value)
399+
values.Add(p.key, p.value)
400400
}
401401
}
402402
}

node.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ walk: // Outer loop for walking the tree
355355
// save param value
356356
i := len(rv.params)
357357
rv.params = rv.params[:i+1] // expand slice within preallocated capacity
358-
rv.params[i].Key = n.path[1:]
359-
rv.params[i].Value = path[:end]
358+
rv.params[i].key = n.path[1:]
359+
rv.params[i].value = path[:end]
360360

361361
// we need to go deeper!
362362
if end < len(path) {
@@ -389,8 +389,8 @@ walk: // Outer loop for walking the tree
389389
// save param value
390390
i := len(rv.params)
391391
rv.params = rv.params[:i+1] // expand slice within preallocated capacity
392-
rv.params[i].Key = WildcardParam
393-
rv.params[i].Value = path[1:]
392+
rv.params[i].key = WildcardParam
393+
rv.params[i].value = path[1:]
394394

395395
handler = n.handler
396396
return

pure.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,19 @@ type Mux struct {
6161
automaticallyHandleOPTIONS bool
6262
}
6363

64-
// Param is a single URL parameter, consisting of a key and a value.
65-
type Param struct {
66-
Key string
67-
Value string
64+
type urlParam struct {
65+
key string
66+
value string
6867
}
6968

70-
// Params is a Param-slice, as returned by the router.
71-
// The slice is ordered, the first URL parameter is also the first slice value.
72-
// It is therefore safe to read values by the index.
73-
type Params []Param
69+
type urlParams []urlParam
7470

7571
// Get returns the URL parameter for the given key, or blank if not found
76-
func (p Params) Get(key string) (param string) {
72+
func (p urlParams) Get(key string) (param string) {
7773

7874
for i := 0; i < len(p); i++ {
79-
if p[i].Key == key {
80-
param = p[i].Value
75+
if p[i].key == key {
76+
param = p[i].value
8177
return
8278
}
8379
}
@@ -123,7 +119,7 @@ func New() *Mux {
123119
p.pool.New = func() interface{} {
124120

125121
rv := &requestVars{
126-
params: make(Params, p.mostParams),
122+
params: make(urlParams, p.mostParams),
127123
}
128124

129125
rv.ctx = context.WithValue(context.Background(), defaultContextIdentifier, rv)

request_vars.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type ReqVars interface {
1010

1111
type requestVars struct {
1212
ctx context.Context // holds a copy of it's parent requestVars
13-
params Params
13+
params urlParams
1414
formParsed bool
1515
}
1616

0 commit comments

Comments
 (0)