Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Public test API to set URL params #322

Merged
merged 3 commits into from
Dec 8, 2017
Merged
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions testing.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package mux

import "net/http"

// TestSetURLParam set url params
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you expand on this? Why it exists, what the normal way of setting params is; URL should also be capitalized.

Copy link
Contributor Author

@grim-fendango grim-fendango Dec 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow thanks for a fast response! 😃 I was just thinking about that myself. I'm just looking up some other concrete examples for this sort of thing and then I'll reword it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:

// TestSetURLParam sets the URL params for the given request, to be accessed via mux.Vars for testing route behaviour.
//
// This API should only be used for testing purposes; it provides a way to inject variables into the request context.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wrote something but yours is nicer. Thanks again.

func TestSetURLParam(r *http.Request, val map[string]string) *http.Request {
return setVars(r, val)
}