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
Łukasz Nowak
caddy
Commits
2ea6c95a
Commit
2ea6c95a
authored
Feb 22, 2016
by
Nathan Probst
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow rewrite status codes to be 2xx and 4xx.
parent
c12847e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
2 deletions
+23
-2
caddy/setup/rewrite.go
caddy/setup/rewrite.go
+2
-2
caddy/setup/rewrite_test.go
caddy/setup/rewrite_test.go
+21
-0
No files found.
caddy/setup/rewrite.go
View file @
2ea6c95a
...
...
@@ -80,8 +80,8 @@ func rewriteParse(c *Controller) ([]rewrite.Rule, error) {
return
nil
,
c
.
ArgErr
()
}
status
,
_
=
strconv
.
Atoi
(
c
.
Val
())
if
status
<
400
||
status
>
499
{
return
nil
,
c
.
Err
(
"status must be 4xx"
)
if
status
<
200
||
(
status
>
299
&&
status
<
400
)
||
status
>
499
{
return
nil
,
c
.
Err
(
"status must be
2xx or
4xx"
)
}
default
:
return
nil
,
c
.
ArgErr
()
...
...
caddy/setup/rewrite_test.go
View file @
2ea6c95a
...
...
@@ -137,6 +137,11 @@ func TestRewriteParse(t *testing.T) {
}`
,
false
,
[]
rewrite
.
Rule
{
&
rewrite
.
ComplexRule
{
Base
:
"/"
,
To
:
"/to"
,
Ifs
:
[]
rewrite
.
If
{{
A
:
"{path}"
,
Operator
:
"is"
,
B
:
"a"
}}},
}},
{
`rewrite {
status 500
}`
,
true
,
[]
rewrite
.
Rule
{
&
rewrite
.
ComplexRule
{},
}},
{
`rewrite {
status 400
}`
,
false
,
[]
rewrite
.
Rule
{
...
...
@@ -153,6 +158,22 @@ func TestRewriteParse(t *testing.T) {
}`
,
true
,
[]
rewrite
.
Rule
{
&
rewrite
.
ComplexRule
{},
}},
{
`rewrite {
status 200
}`
,
false
,
[]
rewrite
.
Rule
{
&
rewrite
.
ComplexRule
{
Base
:
"/"
,
Regexp
:
regexp
.
MustCompile
(
".*"
),
Status
:
200
},
}},
{
`rewrite {
to /to
status 200
}`
,
false
,
[]
rewrite
.
Rule
{
&
rewrite
.
ComplexRule
{
Base
:
"/"
,
To
:
"/to"
,
Regexp
:
regexp
.
MustCompile
(
".*"
),
Status
:
200
},
}},
{
`rewrite {
status 199
}`
,
true
,
[]
rewrite
.
Rule
{
&
rewrite
.
ComplexRule
{},
}},
{
`rewrite {
status 0
}`
,
true
,
[]
rewrite
.
Rule
{
...
...
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