Skip to content

Commit 20e7136

Browse files
author
Dean Karn
authored
updates (#11)
- Updated to latest github.com/go-playground/pkg/v5 - Added EncodeToURLValues helper - Updated to use GitHub Actions for CI
1 parent 5427a09 commit 20e7136

12 files changed

+74
-46
lines changed

.github/workflows/go.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Lint & Test
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
strategy:
6+
matrix:
7+
go-version: [1.14.x,1.13.x]
8+
platform: [ubuntu-latest, macos-latest, windows-latest]
9+
runs-on: ${{ matrix.platform }}
10+
steps:
11+
- name: Install Go
12+
uses: actions/setup-go@v1
13+
with:
14+
go-version: ${{ matrix.go-version }}
15+
16+
- name: Priming Cache
17+
uses: actions/cache@v1
18+
with:
19+
path: ~/go/pkg/mod
20+
key: ${{ runner.os }}-v1-go-${{ hashFiles('**/go.sum') }}
21+
restore-keys: |
22+
${{ runner.os }}-v1-go-
23+
24+
- name: Checkout code
25+
uses: actions/checkout@v2
26+
27+
- name: Lint
28+
if: matrix.platform == 'ubuntu-latest' && matrix.go-version == '1.14.x'
29+
run: |
30+
export PATH=$PATH:$(go env GOPATH)/bin # temporary fix. See https://github.com/actions/setup-go/issues/14
31+
go get -u golang.org/x/lint/golint
32+
golint -set_exit_status ./...
33+
34+
- name: Test
35+
run: go test ./...

.travis.yml

-26
This file was deleted.

Makefile

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
GOCMD=GO111MODULE=on go
22

3-
linters-install:
4-
@golangci-lint --version >/dev/null 2>&1 || { \
5-
echo "installing linting tools..."; \
6-
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.21.0; \
7-
}
8-
9-
lint: linters-install
10-
$(PWD)/bin/golangci-lint run
3+
lint:
4+
golint -set_exit_status ./...
115

126
test:
137
$(GOCMD) test -cover -race ./...
148

159
bench:
1610
$(GOCMD) test -bench=. -benchmem ./...
1711

18-
.PHONY: linters-install lint test bench
12+
.PHONY: lint test bench

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package pure
22
============
3-
<img align="right" src="https://raw.githubusercontent.com/go-playground/pure/master/logo.png">![Project status](https://img.shields.io/badge/version-5.0.5-green.svg)
3+
<img align="right" src="https://raw.githubusercontent.com/go-playground/pure/master/logo.png">![Project status](https://img.shields.io/badge/version-5.1.0-green.svg)
44
[![Build Status](https://travis-ci.org/go-playground/pure.svg?branch=master)](https://travis-ci.org/go-playground/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)
7-
[![GoDoc](https://godoc.org/github.com/go-playground/pure?status.svg)](https://godoc.org/github.com/go-playground/pure)
7+
[![GoDoc](https://godoc.org/github.com/go-playground/pure?status.svg)](https://pkg.go.dev/github.com/go-playground/pure)
88
![License](https://img.shields.io/dub/l/vibe-d.svg)
99
[![Gitter](https://badges.gitter.im/go-playground/pure.svg)](https://gitter.im/go-playground/pure?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
1010

1111
Pure is a fast radix-tree based HTTP router that sticks to the native implementations of Go's "net/http" package;
1212
in essence, keeping the handler implementations 'pure' by using Go 1.7's "context" package.
1313

14-
This makes heavy usage of `github.com/go-playground/pkg/v4` for HTTP abstractions.
14+
This makes heavy usage of `github.com/go-playground/pkg/v5` for HTTP abstractions.
1515

1616
Why Another HTTP Router?
1717
------------------------

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/go-playground/pure/v5
22

33
require (
44
github.com/go-playground/assert/v2 v2.0.1
5-
github.com/go-playground/pkg/v4 v4.0.0
5+
github.com/go-playground/pkg/v5 v5.1.0
66
)
77

8-
go 1.13
8+
go 1.14

go.sum

+6
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,11 @@ github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBY
44
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
55
github.com/go-playground/form/v4 v4.0.0 h1:vUKi2K1Hqlc4rpBc0tCclgs9zSfbY5yMKsL106db/eY=
66
github.com/go-playground/form/v4 v4.0.0/go.mod h1:bodWfd97U9PVMZFcDsbVzSbQQTtaWrebnTwQtWjSW1M=
7+
github.com/go-playground/form/v4 v4.1.1 h1:1T9lGt3WRHuDwT5uwx7RYQZfxVwWZhF0DC1ovKyNnWY=
8+
github.com/go-playground/form/v4 v4.1.1/go.mod h1:q1a2BY+AQUUzhl6xA/6hBetay6dEIhMHjgvJiGo6K7U=
9+
github.com/go-playground/pkg v1.0.1 h1:EsBCgjDTrlaLCflFChT2Q/M4unQQS6DnBDvHTA+fVAI=
10+
github.com/go-playground/pkg v1.0.1/go.mod h1:P1pn/auRkxPy9n7eXlvyyJpBIvxdH6ZUtHOGOLfBaBA=
711
github.com/go-playground/pkg/v4 v4.0.0 h1:0lTr9H8RyCwom4TcfNhMCNvlTlFuin7uUlXcZQuxrA4=
812
github.com/go-playground/pkg/v4 v4.0.0/go.mod h1:TLowM3d3a/m04JlHK/zM6Ia8zf8+0C/9pTwhDEUqKO0=
13+
github.com/go-playground/pkg/v5 v5.1.0 h1:odCGeJgAQFjoU8eMfT0jjqeMoa4KspymUIq+vi5NpEk=
14+
github.com/go-playground/pkg/v5 v5.1.0/go.mod h1:0380E0lsFB1POWFypOLL8tX2f0O1OBCBpSdVmEy4mg0=

helpers.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import (
66
"net/url"
77
"strings"
88

9-
httpext "github.com/go-playground/pkg/v4/net/http"
9+
httpext "github.com/go-playground/pkg/v5/net/http"
10+
urlext "github.com/go-playground/pkg/v5/net/url"
1011
)
1112

1213
// RequestVars returns the request scoped variables tracked by pure
@@ -236,3 +237,8 @@ func QueryParams(r *http.Request, qp httpext.QueryParamsOption) (values url.Valu
236237
}
237238
return
238239
}
240+
241+
// EncodeToURLValues encodes a struct or field into a set of url.Values
242+
func EncodeToURLValues(v interface{}) (url.Values, error) {
243+
return urlext.EncodeToURLValues(v)
244+
}

helpers_test.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"sync"
1919
"testing"
2020

21-
httpext "github.com/go-playground/pkg/v4/net/http"
21+
httpext "github.com/go-playground/pkg/v5/net/http"
2222

2323
. "github.com/go-playground/assert/v2"
2424
)
@@ -662,6 +662,19 @@ func TestBadParseMultiPartForm(t *testing.T) {
662662
Equal(t, body, "invalid URL escape \"%%e\"")
663663
}
664664

665+
func TestEncodeToURLValues(t *testing.T) {
666+
type Test struct {
667+
Domain string `form:"domain"`
668+
Next string `form:"next"`
669+
}
670+
671+
s := Test{Domain: "company.org", Next: "NIDEJ89#(@#NWJK"}
672+
values, err := EncodeToURLValues(s)
673+
Equal(t, err, nil)
674+
Equal(t, len(values), 2)
675+
Equal(t, values.Encode(), "domain=company.org&next=NIDEJ89%23%28%40%23NWJK")
676+
}
677+
665678
type gzipWriter struct {
666679
io.Writer
667680
http.ResponseWriter

middleware/gzip.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"strings"
1111
"sync"
1212

13-
httpext "github.com/go-playground/pkg/v4/net/http"
13+
httpext "github.com/go-playground/pkg/v5/net/http"
1414

1515
"github.com/go-playground/pure/v5"
1616
)

middleware/gzip_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"net/http/httptest"
1212
"testing"
1313

14-
httpext "github.com/go-playground/pkg/v4/net/http"
14+
httpext "github.com/go-playground/pkg/v5/net/http"
1515

1616
. "github.com/go-playground/assert/v2"
1717
"github.com/go-playground/pure/v5"

pure.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strings"
77
"sync"
88

9-
httpext "github.com/go-playground/pkg/v4/net/http"
9+
httpext "github.com/go-playground/pkg/v5/net/http"
1010
)
1111

1212
var (

pure_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"testing"
1313

1414
. "github.com/go-playground/assert/v2"
15-
httpext "github.com/go-playground/pkg/v4/net/http"
15+
httpext "github.com/go-playground/pkg/v5/net/http"
1616
)
1717

1818
// NOTES:

0 commit comments

Comments
 (0)