Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
heroku-buildpack-static
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Python-Dev
heroku-buildpack-static
Commits
418a9b0b
Commit
418a9b0b
authored
Jun 05, 2015
by
Terence Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make the trailing slash in proxies' origin optional in static.json
parent
70578df9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
8 deletions
+34
-8
make-config
scripts/config/make-config
+5
-0
simple_spec.rb
spec/simple_spec.rb
+29
-8
No files found.
scripts/config/make-config
View file @
418a9b0b
...
...
@@ -18,6 +18,11 @@ class NginxConfig
json
[
"port"
]
||=
ENV
[
"PORT"
]
||
5000
json
[
"root"
]
||=
"public_html/"
json
[
"proxies"
]
||=
{}
json
[
"proxies"
].
each
do
|
loc
,
hash
|
if
hash
[
"origin"
][
-
1
]
!=
"/"
json
[
"proxies"
][
loc
].
merge!
(
"origin"
=>
hash
[
"origin"
]
+
"/"
)
end
end
json
[
"clean_urls"
]
||=
false
json
[
"routes"
]
||=
{}
json
[
"routes"
]
=
Hash
[
json
[
"routes"
].
map
{
|
route
,
target
|
[
to_regex
(
route
),
target
]
}]
...
...
spec/simple_spec.rb
View file @
418a9b0b
...
...
@@ -85,19 +85,22 @@ RSpec.describe "Simple" do
describe
"proxies"
do
include
PathHelper
let
(
:name
)
{
"proxies"
}
let
(
:static_json_path
)
{
fixtures_path
(
"proxies/static.json"
)
}
before
do
let
(
:name
)
{
"proxies"
}
let
(
:static_json_path
)
{
fixtures_path
(
"proxies/static.json"
)
}
let
(
:setup_static_json
)
do
Proc
.
new
do
|
path
|
File
.
open
(
static_json_path
,
"w"
)
do
|
file
|
file
.
puts
<<
STATIC_JSON
{
"proxies": {
"/api/": {
"origin": "http://
#{
AppRunner
::
HOST_IP
}
:
#{
AppRunner
::
HOST_PORT
}
/foo/
"
"origin": "http://
#{
AppRunner
::
HOST_IP
}
:
#{
AppRunner
::
HOST_PORT
}
#{
path
}
"
}
}
}
STATIC_JSON
end
end
end
...
...
@@ -105,10 +108,28 @@ STATIC_JSON
FileUtils
.
rm
(
static_json_path
)
end
it
"should proxy requests"
do
response
=
app
.
get
(
"/api/bar/"
)
expect
(
response
.
code
).
to
eq
(
"200"
)
expect
(
response
.
body
.
chomp
).
to
eq
(
"api"
)
context
"trailing slash"
do
before
do
setup_static_json
.
call
(
"/foo/"
)
end
it
"should proxy requests"
do
response
=
app
.
get
(
"/api/bar/"
)
expect
(
response
.
code
).
to
eq
(
"200"
)
expect
(
response
.
body
.
chomp
).
to
eq
(
"api"
)
end
end
context
"without a trailing slash"
do
before
do
setup_static_json
.
call
(
"/foo"
)
end
it
"should proxy requests"
do
response
=
app
.
get
(
"/api/bar/"
)
expect
(
response
.
code
).
to
eq
(
"200"
)
expect
(
response
.
body
.
chomp
).
to
eq
(
"api"
)
end
end
end
end
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