Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
612d77ea
Commit
612d77ea
authored
Jan 29, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved Path type around
parent
04996b28
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
16 deletions
+16
-16
middleware/headers/headers.go
middleware/headers/headers.go
+2
-2
middleware/middleware.go
middleware/middleware.go
+1
-14
middleware/path.go
middleware/path.go
+13
-0
No files found.
middleware/headers/headers.go
View file @
612d77ea
...
...
@@ -3,7 +3,7 @@ package headers
import
(
"net/http"
"github.com/mholt/caddy/middleware
/util
"
"github.com/mholt/caddy/middleware"
)
// Headers is middleware that adds headers to the responses
...
...
@@ -17,7 +17,7 @@ type Headers struct {
// adding headers to the response according to the configured rules.
func
(
h
*
Headers
)
ServeHTTP
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
for
_
,
rule
:=
range
h
.
rules
{
if
util
.
Path
(
r
.
URL
.
Path
)
.
Matches
(
rule
.
Url
)
{
if
middleware
.
Path
(
r
.
URL
.
Path
)
.
Matches
(
rule
.
Url
)
{
for
_
,
header
:=
range
rule
.
Headers
{
w
.
Header
()
.
Set
(
header
.
Name
,
header
.
Value
)
}
...
...
middleware/middleware.go
View file @
612d77ea
...
...
@@ -2,10 +2,7 @@
// the servers to use, according to their configuration.
package
middleware
import
(
"net/http"
"strings"
)
import
"net/http"
type
(
// Generator represents the outer layer of a middleware that
...
...
@@ -35,13 +32,3 @@ type (
Port
()
string
}
)
// Path represents a URI path, maybe with pattern characters.
type
Path
string
// Path matching will probably not always be a direct
// comparison; this method assures that paths can be
// easily matched.
func
(
p
Path
)
Matches
(
other
string
)
bool
{
return
strings
.
HasPrefix
(
string
(
p
),
other
)
}
middleware/path.go
0 → 100644
View file @
612d77ea
package
middleware
import
"strings"
// Path represents a URI path, maybe with pattern characters.
type
Path
string
// Path matching will probably not always be a direct
// comparison; this method assures that paths can be
// easily matched.
func
(
p
Path
)
Matches
(
other
string
)
bool
{
return
strings
.
HasPrefix
(
string
(
p
),
other
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment