Skip to content

Commit 1848864

Browse files
Dean KarnDean Karn
authored andcommitted
update Pure struct to Mux to reduce stutter
1 parent 07272c4 commit 1848864

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
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-1.1.0-green.svg)
3+
![Project status](https://img.shields.io/badge/version-1.2.0-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)

group.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type IRoutes interface {
3131
type routeGroup struct {
3232
prefix string
3333
middleware []Middleware
34-
pure *Pure
34+
pure *Mux
3535
}
3636

3737
var _ IRouteGroup = &routeGroup{}

pure.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ var (
2424
xmlHeaderBytes = []byte(xml.Header)
2525
)
2626

27-
// Pure is the main instance
28-
type Pure struct {
27+
// Mux is the main request multiplexer
28+
type Mux struct {
2929
routeGroup
3030
get *node
3131
post *node
@@ -112,9 +112,9 @@ var (
112112
)
113113

114114
// New Creates and returns a new Pure instance
115-
func New() *Pure {
115+
func New() *Mux {
116116

117-
p := &Pure{
117+
p := &Mux{
118118
routeGroup: routeGroup{
119119
middleware: make([]Middleware, 0),
120120
},
@@ -150,7 +150,7 @@ func New() *Pure {
150150

151151
// Register404 alows for overriding of the not found handler function.
152152
// NOTE: this is run after not finding a route even after redirecting with the trailing slash
153-
func (p *Pure) Register404(notFound http.HandlerFunc, middleware ...Middleware) {
153+
func (p *Mux) Register404(notFound http.HandlerFunc, middleware ...Middleware) {
154154

155155
h := notFound
156156

@@ -164,7 +164,7 @@ func (p *Pure) Register404(notFound http.HandlerFunc, middleware ...Middleware)
164164
// RegisterAutomaticOPTIONS tells pure whether to
165165
// automatically handle OPTION requests; manually configured
166166
// OPTION handlers take precedence. default true
167-
func (p *Pure) RegisterAutomaticOPTIONS(middleware ...Middleware) {
167+
func (p *Mux) RegisterAutomaticOPTIONS(middleware ...Middleware) {
168168

169169
p.automaticallyHandleOPTIONS = true
170170

@@ -180,13 +180,13 @@ func (p *Pure) RegisterAutomaticOPTIONS(middleware ...Middleware) {
180180
// SetRedirectTrailingSlash tells pure whether to try
181181
// and fix a URL by trying to find it
182182
// lowercase -> with or without slash -> 404
183-
func (p *Pure) SetRedirectTrailingSlash(set bool) {
183+
func (p *Mux) SetRedirectTrailingSlash(set bool) {
184184
p.redirectTrailingSlash = set
185185
}
186186

187187
// RegisterMethodNotAllowed tells pure whether to
188188
// handle the http 405 Method Not Allowed status code
189-
func (p *Pure) RegisterMethodNotAllowed(middleware ...Middleware) {
189+
func (p *Mux) RegisterMethodNotAllowed(middleware ...Middleware) {
190190

191191
p.handleMethodNotAllowed = true
192192

@@ -200,7 +200,7 @@ func (p *Pure) RegisterMethodNotAllowed(middleware ...Middleware) {
200200
}
201201

202202
// Serve returns an http.Handler to be used.
203-
func (p *Pure) Serve() http.Handler {
203+
func (p *Mux) Serve() http.Handler {
204204

205205
// reserved for any logic that needs to happen before serving starts.
206206
// i.e. although this router does not use priority to determine route order
@@ -210,7 +210,7 @@ func (p *Pure) Serve() http.Handler {
210210
}
211211

212212
// Conforms to the http.Handler interface.
213-
func (p *Pure) serveHTTP(w http.ResponseWriter, r *http.Request) {
213+
func (p *Mux) serveHTTP(w http.ResponseWriter, r *http.Request) {
214214

215215
var tree *node
216216

@@ -504,7 +504,7 @@ END:
504504
p.pool.Put(rv)
505505
}
506506

507-
func (p *Pure) redirect(method string, to string) (h http.HandlerFunc) {
507+
func (p *Mux) redirect(method string, to string) (h http.HandlerFunc) {
508508

509509
code := http.StatusMovedPermanently
510510

pure_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ func (c *closeNotifyingRecorder) CloseNotify() <-chan bool {
858858
return c.closed
859859
}
860860

861-
func request(method, path string, p *Pure) (int, string) {
861+
func request(method, path string, p *Mux) (int, string) {
862862
r, _ := http.NewRequest(method, path, nil)
863863
w := &closeNotifyingRecorder{
864864
httptest.NewRecorder(),
@@ -869,7 +869,7 @@ func request(method, path string, p *Pure) (int, string) {
869869
return w.Code, w.Body.String()
870870
}
871871

872-
func requestMultiPart(method string, url string, p *Pure) (int, string) {
872+
func requestMultiPart(method string, url string, p *Mux) (int, string) {
873873

874874
body := &bytes.Buffer{}
875875
writer := multipart.NewWriter(body)

0 commit comments

Comments
 (0)