Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Lint & Test
on: [push, pull_request]
jobs:
test:
strategy:
matrix:
go-version: [1.14.x,1.13.x]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go-version }}

- name: Priming Cache
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-v1-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-v1-go-

- name: Checkout code
uses: actions/checkout@v2

- name: Lint
if: matrix.platform == 'ubuntu-latest' && matrix.go-version == '1.14.x'
run: |
export PATH=$PATH:$(go env GOPATH)/bin # temporary fix. See https://github.com/actions/setup-go/issues/14
go get -u golang.org/x/lint/golint
golint -set_exit_status ./...

- name: Test
run: go test ./...
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

12 changes: 3 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
GOCMD=GO111MODULE=on go

linters-install:
@golangci-lint --version >/dev/null 2>&1 || { \
echo "installing linting tools..."; \
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.21.0; \
}

lint: linters-install
$(PWD)/bin/golangci-lint run
lint:
golint -set_exit_status ./...

test:
$(GOCMD) test -cover -race ./...

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

.PHONY: linters-install lint test bench
.PHONY: lint test bench
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package pure
============
<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)
<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)
[![Build Status](https://travis-ci.org/go-playground/pure.svg?branch=master)](https://travis-ci.org/go-playground/pure)
[![Coverage Status](https://coveralls.io/repos/github/go-playground/pure/badge.svg?branch=master)](https://coveralls.io/github/go-playground/pure?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/pure)](https://goreportcard.com/report/github.com/go-playground/pure)
[![GoDoc](https://godoc.org/github.com/go-playground/pure?status.svg)](https://godoc.org/github.com/go-playground/pure)
[![GoDoc](https://godoc.org/github.com/go-playground/pure?status.svg)](https://pkg.go.dev/github.com/go-playground/pure)
![License](https://img.shields.io/dub/l/vibe-d.svg)
[![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)

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

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

Why Another HTTP Router?
------------------------
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/go-playground/pure/v5

require (
github.com/go-playground/assert/v2 v2.0.1
github.com/go-playground/pkg/v4 v4.0.0
github.com/go-playground/pkg/v5 v5.1.0
)

go 1.13
go 1.14
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@ github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBY
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/form/v4 v4.0.0 h1:vUKi2K1Hqlc4rpBc0tCclgs9zSfbY5yMKsL106db/eY=
github.com/go-playground/form/v4 v4.0.0/go.mod h1:bodWfd97U9PVMZFcDsbVzSbQQTtaWrebnTwQtWjSW1M=
github.com/go-playground/form/v4 v4.1.1 h1:1T9lGt3WRHuDwT5uwx7RYQZfxVwWZhF0DC1ovKyNnWY=
github.com/go-playground/form/v4 v4.1.1/go.mod h1:q1a2BY+AQUUzhl6xA/6hBetay6dEIhMHjgvJiGo6K7U=
github.com/go-playground/pkg v1.0.1 h1:EsBCgjDTrlaLCflFChT2Q/M4unQQS6DnBDvHTA+fVAI=
github.com/go-playground/pkg v1.0.1/go.mod h1:P1pn/auRkxPy9n7eXlvyyJpBIvxdH6ZUtHOGOLfBaBA=
github.com/go-playground/pkg/v4 v4.0.0 h1:0lTr9H8RyCwom4TcfNhMCNvlTlFuin7uUlXcZQuxrA4=
github.com/go-playground/pkg/v4 v4.0.0/go.mod h1:TLowM3d3a/m04JlHK/zM6Ia8zf8+0C/9pTwhDEUqKO0=
github.com/go-playground/pkg/v5 v5.1.0 h1:odCGeJgAQFjoU8eMfT0jjqeMoa4KspymUIq+vi5NpEk=
github.com/go-playground/pkg/v5 v5.1.0/go.mod h1:0380E0lsFB1POWFypOLL8tX2f0O1OBCBpSdVmEy4mg0=
8 changes: 7 additions & 1 deletion helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import (
"net/url"
"strings"

httpext "github.com/go-playground/pkg/v4/net/http"
httpext "github.com/go-playground/pkg/v5/net/http"
urlext "github.com/go-playground/pkg/v5/net/url"
)

// RequestVars returns the request scoped variables tracked by pure
Expand Down Expand Up @@ -236,3 +237,8 @@ func QueryParams(r *http.Request, qp httpext.QueryParamsOption) (values url.Valu
}
return
}

// EncodeToURLValues encodes a struct or field into a set of url.Values
func EncodeToURLValues(v interface{}) (url.Values, error) {
return urlext.EncodeToURLValues(v)
}
15 changes: 14 additions & 1 deletion helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"sync"
"testing"

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

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

func TestEncodeToURLValues(t *testing.T) {
type Test struct {
Domain string `form:"domain"`
Next string `form:"next"`
}

s := Test{Domain: "company.org", Next: "NIDEJ89#(@#NWJK"}
values, err := EncodeToURLValues(s)
Equal(t, err, nil)
Equal(t, len(values), 2)
Equal(t, values.Encode(), "domain=company.org&next=NIDEJ89%23%28%40%23NWJK")
}

type gzipWriter struct {
io.Writer
http.ResponseWriter
Expand Down
2 changes: 1 addition & 1 deletion middleware/gzip.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"
"sync"

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

"github.com/go-playground/pure/v5"
)
Expand Down
2 changes: 1 addition & 1 deletion middleware/gzip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"net/http/httptest"
"testing"

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

. "github.com/go-playground/assert/v2"
"github.com/go-playground/pure/v5"
Expand Down
2 changes: 1 addition & 1 deletion pure.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"sync"

httpext "github.com/go-playground/pkg/v4/net/http"
httpext "github.com/go-playground/pkg/v5/net/http"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion pure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"testing"

. "github.com/go-playground/assert/v2"
httpext "github.com/go-playground/pkg/v4/net/http"
httpext "github.com/go-playground/pkg/v5/net/http"
)

// NOTES:
Expand Down