Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
D
dalmatinerfe
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
3
Issues
3
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Project-FiFo
DalmatinerDB
dalmatinerfe
Commits
a27fd3a4
Commit
a27fd3a4
authored
Sep 01, 2016
by
Heinz N. Gies
Committed by
GitHub
Sep 01, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19 from dataloop/cors-middleware
CORS middleware
parents
7c26a1d6
05782ec8
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
42 additions
and
35 deletions
+42
-35
apps/dalmatiner_frontend/src/dalmatiner_bucket_h.erl
apps/dalmatiner_frontend/src/dalmatiner_bucket_h.erl
+1
-4
apps/dalmatiner_frontend/src/dalmatiner_collection_h.erl
apps/dalmatiner_frontend/src/dalmatiner_collection_h.erl
+1
-4
apps/dalmatiner_frontend/src/dalmatiner_cors_m.erl
apps/dalmatiner_frontend/src/dalmatiner_cors_m.erl
+28
-0
apps/dalmatiner_frontend/src/dalmatiner_frontend_app.erl
apps/dalmatiner_frontend/src/dalmatiner_frontend_app.erl
+5
-1
apps/dalmatiner_frontend/src/dalmatiner_function_h.erl
apps/dalmatiner_frontend/src/dalmatiner_function_h.erl
+1
-4
apps/dalmatiner_frontend/src/dalmatiner_idx_handler.erl
apps/dalmatiner_frontend/src/dalmatiner_idx_handler.erl
+1
-3
apps/dalmatiner_frontend/src/dalmatiner_key_h.erl
apps/dalmatiner_frontend/src/dalmatiner_key_h.erl
+1
-3
apps/dalmatiner_frontend/src/dalmatiner_metric_h.erl
apps/dalmatiner_frontend/src/dalmatiner_metric_h.erl
+1
-4
apps/dalmatiner_frontend/src/dalmatiner_namespace_h.erl
apps/dalmatiner_frontend/src/dalmatiner_namespace_h.erl
+1
-4
apps/dalmatiner_frontend/src/dalmatiner_tag_h.erl
apps/dalmatiner_frontend/src/dalmatiner_tag_h.erl
+1
-4
apps/dalmatiner_frontend/src/dalmatiner_value_h.erl
apps/dalmatiner_frontend/src/dalmatiner_value_h.erl
+1
-4
No files found.
apps/dalmatiner_frontend/src/dalmatiner_bucket_h.erl
View file @
a27fd3a4
...
...
@@ -11,10 +11,7 @@ init(_Transport, Req, []) ->
-
dialyzer
({
no_opaque
,
handle
/
2
}).
handle
(
Req
,
State
)
->
Req0
=
cowboy_req
:
set_resp_header
(
<<
"access-control-allow-origin"
>>
,
<<
"*"
>>
,
Req
),
{
ContentType
,
Req1
}
=
dalmatiner_idx_handler
:
content_type
(
Req0
),
{
ContentType
,
Req1
}
=
dalmatiner_idx_handler
:
content_type
(
Req
),
case
ContentType
of
html
->
F
=
fun
(
Socket
,
Transport
)
->
...
...
apps/dalmatiner_frontend/src/dalmatiner_collection_h.erl
View file @
a27fd3a4
...
...
@@ -11,10 +11,7 @@ init(_Transport, Req, []) ->
-
dialyzer
({
no_opaque
,
handle
/
2
}).
handle
(
Req
,
State
)
->
Req0
=
cowboy_req
:
set_resp_header
(
<<
"access-control-allow-origin"
>>
,
<<
"*"
>>
,
Req
),
{
ContentType
,
Req1
}
=
dalmatiner_idx_handler
:
content_type
(
Req0
),
{
ContentType
,
Req1
}
=
dalmatiner_idx_handler
:
content_type
(
Req
),
case
ContentType
of
html
->
F
=
fun
(
Socket
,
Transport
)
->
...
...
apps/dalmatiner_frontend/src/dalmatiner_cors_m.erl
0 → 100644
View file @
a27fd3a4
-
module
(
dalmatiner_cors_m
).
-
behaviour
(
cowboy_middleware
).
-
export
([
execute
/
2
]).
%%
%% CORS middleware
%% =====================================
-
spec
execute
(
cowboy_req
:
req
(),
[{
atom
(),
any
()}])
->
{
ok
,
cowboy_req
:
req
(),
[{
atom
(),
any
()}]}
|
{
halt
,
cowboy_req
:
req
()}.
execute
(
Req
,
Env
)
->
R1
=
cowboy_req
:
set_resp_header
(
<<
"access-control-allow-origin"
>>
,
<<
"*"
>>
,
Req
),
case
cowboy_req
:
method
(
R1
)
of
{
<<
"OPTIONS"
>>
,
R2
}
->
R3
=
cowboy_req
:
set_resp_header
(
<<
"access-control-allow-methods"
>>
,
<<
"GET"
>>
,
R2
),
R4
=
cowboy_req
:
set_resp_header
(
<<
"access-control-allow-headers"
>>
,
<<
"Authorization"
>>
,
R3
),
R5
=
cowboy_req
:
set_resp_header
(
<<
"access-control-max-age"
>>
,
<<
"3600"
>>
,
R4
),
{
ok
,
R6
}
=
cowboy_req
:
reply
(
200
,
R5
),
{
halt
,
R6
};
{_,
R2
}
->
{
ok
,
R2
,
Env
}
end
.
apps/dalmatiner_frontend/src/dalmatiner_frontend_app.erl
View file @
a27fd3a4
...
...
@@ -75,7 +75,11 @@ start(_StartType, _StartArgs) ->
%% Name, NbAcceptors, TransOpts, ProtoOpts
{
ok
,
_}
=
cowboy
:
start_http
(
dalmatiner_http_listener
,
Listeners
,
[{
port
,
Port
}],
[{
env
,
[{
dispatch
,
Dispatch
}]},
[{
env
,
[{
dispatch
,
Dispatch
}]}
{
middlewares
,
[
cowboy_router
,
dalmatiner_cors_m
,
cowboy_handler
]},
{
max_keepalive
,
5
},
{
timeout
,
50000
}]),
dalmatiner_frontend_sup
:
start_link
().
...
...
apps/dalmatiner_frontend/src/dalmatiner_function_h.erl
View file @
a27fd3a4
...
...
@@ -11,10 +11,7 @@ init(_Transport, Req, []) ->
-
dialyzer
({
no_opaque
,
handle
/
2
}).
handle
(
Req
,
State
)
->
Req0
=
cowboy_req
:
set_resp_header
(
<<
"access-control-allow-origin"
>>
,
<<
"*"
>>
,
Req
),
{
ContentType
,
Req1
}
=
dalmatiner_idx_handler
:
content_type
(
Req0
),
{
ContentType
,
Req1
}
=
dalmatiner_idx_handler
:
content_type
(
Req
),
case
ContentType
of
html
->
F
=
fun
(
Socket
,
Transport
)
->
...
...
apps/dalmatiner_frontend/src/dalmatiner_idx_handler.erl
View file @
a27fd3a4
...
...
@@ -10,9 +10,7 @@ init(_Transport, Req, []) ->
-
dialyzer
({
no_opaque
,
handle
/
2
}).
handle
(
Req
,
State
)
->
Req0
=
cowboy_req
:
set_resp_header
(
<<
"access-control-allow-origin"
>>
,
<<
"*"
>>
,
Req
),
case
cowboy_req
:
qs_val
(
<<
"q"
>>
,
Req0
)
of
case
cowboy_req
:
qs_val
(
<<
"q"
>>
,
Req
)
of
{
undefined
,
Req1
}
->
F
=
fun
(
Socket
,
Transport
)
->
File
=
code
:
priv_dir
(
dalmatiner_frontend
)
++
...
...
apps/dalmatiner_frontend/src/dalmatiner_key_h.erl
View file @
a27fd3a4
...
...
@@ -11,9 +11,7 @@ init(_Transport, Req, []) ->
-
dialyzer
({
no_opaque
,
handle
/
2
}).
handle
(
Req
,
State
)
->
Req0
=
cowboy_req
:
set_resp_header
(
<<
"access-control-allow-origin"
>>
,
<<
"*"
>>
,
Req
),
{[
Bucket
|
Path
],
Req1
}
=
cowboy_req
:
path_info
(
Req0
),
{[
Bucket
|
Path
],
Req1
}
=
cowboy_req
:
path_info
(
Req
),
{
ContentType
,
Req2
}
=
dalmatiner_idx_handler
:
content_type
(
Req1
),
case
ContentType
of
html
->
...
...
apps/dalmatiner_frontend/src/dalmatiner_metric_h.erl
View file @
a27fd3a4
...
...
@@ -11,10 +11,7 @@ init(_Transport, Req, []) ->
-
dialyzer
({
no_opaque
,
handle
/
2
}).
handle
(
Req
,
State
)
->
Req0
=
cowboy_req
:
set_resp_header
(
<<
"access-control-allow-origin"
>>
,
<<
"*"
>>
,
Req
),
{
ContentType
,
Req1
}
=
dalmatiner_idx_handler
:
content_type
(
Req0
),
{
ContentType
,
Req1
}
=
dalmatiner_idx_handler
:
content_type
(
Req
),
case
ContentType
of
html
->
F
=
fun
(
Socket
,
Transport
)
->
...
...
apps/dalmatiner_frontend/src/dalmatiner_namespace_h.erl
View file @
a27fd3a4
...
...
@@ -11,10 +11,7 @@ init(_Transport, Req, []) ->
-
dialyzer
({
no_opaque
,
handle
/
2
}).
handle
(
Req
,
State
)
->
Req0
=
cowboy_req
:
set_resp_header
(
<<
"access-control-allow-origin"
>>
,
<<
"*"
>>
,
Req
),
{
ContentType
,
Req1
}
=
dalmatiner_idx_handler
:
content_type
(
Req0
),
{
ContentType
,
Req1
}
=
dalmatiner_idx_handler
:
content_type
(
Req
),
case
ContentType
of
html
->
F
=
fun
(
Socket
,
Transport
)
->
...
...
apps/dalmatiner_frontend/src/dalmatiner_tag_h.erl
View file @
a27fd3a4
...
...
@@ -11,10 +11,7 @@ init(_Transport, Req, []) ->
-
dialyzer
({
no_opaque
,
handle
/
2
}).
handle
(
Req
,
State
)
->
Req0
=
cowboy_req
:
set_resp_header
(
<<
"access-control-allow-origin"
>>
,
<<
"*"
>>
,
Req
),
{
ContentType
,
Req1
}
=
dalmatiner_idx_handler
:
content_type
(
Req0
),
{
ContentType
,
Req1
}
=
dalmatiner_idx_handler
:
content_type
(
Req
),
case
ContentType
of
html
->
F
=
fun
(
Socket
,
Transport
)
->
...
...
apps/dalmatiner_frontend/src/dalmatiner_value_h.erl
View file @
a27fd3a4
...
...
@@ -11,10 +11,7 @@ init(_Transport, Req, []) ->
-
dialyzer
({
no_opaque
,
handle
/
2
}).
handle
(
Req
,
State
)
->
Req0
=
cowboy_req
:
set_resp_header
(
<<
"access-control-allow-origin"
>>
,
<<
"*"
>>
,
Req
),
{
ContentType
,
Req1
}
=
dalmatiner_idx_handler
:
content_type
(
Req0
),
{
ContentType
,
Req1
}
=
dalmatiner_idx_handler
:
content_type
(
Req
),
case
ContentType
of
html
->
F
=
fun
(
Socket
,
Transport
)
->
...
...
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