Skip to content

Commit

Permalink
export parseParam
Browse files Browse the repository at this point in the history
  • Loading branch information
gernest committed Jan 29, 2018
1 parent e302828 commit a9d7698
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions alien.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (r *route) ServeHTTP(w http.ResponseWriter, req *http.Request) {
base.ServeHTTP(w, req)
}

// parseParams parses params found in mateched from pattern. There are two kinds
// ParseParams parses params found in mateched from pattern. There are two kinds
// of params, one to capture a segment which starts with : and a nother to
// capture everything( a.k.a catch all) whis starts with *.
//
Expand All @@ -179,7 +179,7 @@ func (r *route) ServeHTTP(w http.ResponseWriter, req *http.Request) {
// Will result into name:world. this function captures the named params and
// theri coreesponding values, returning them in a comma separated string of a
// key:value nature. please see the tests for more details.
func parseParams(matched, pattern string) (result string, err error) {
func ParseParams(matched, pattern string) (result string, err error) {
if strings.Contains(pattern, ":") || strings.Contains(pattern, "*") {
p1 := strings.Split(matched, "/")
p2 := strings.Split(pattern, "/")
Expand Down Expand Up @@ -463,7 +463,7 @@ func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request) {
m.notFound.ServeHTTP(w, r)
return
}
params, _ := parseParams(p, h.path) // check if there is any url params
params, _ := ParseParams(p, h.path) // check if there is any url params
if params != "" {
r.Header.Set(headerName, params)
}
Expand Down
2 changes: 1 addition & 1 deletion alien_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestParseParams(t *testing.T) {
}

for _, v := range sample {
n, err := parseParams(v.match, v.pattern)
n, err := ParseParams(v.match, v.pattern)
if err != nil {
t.Error(err)
}
Expand Down

0 comments on commit a9d7698

Please sign in to comment.