Skip to content

Commit 36bb9de

Browse files
authored
Merge pull request #66 from robkooper/fix-proxy-and-more
Fix proxy and more
2 parents 6ef6f15 + 43dd460 commit 36bb9de

File tree

6 files changed

+26
-15
lines changed

6 files changed

+26
-15
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## Unreleased
8+
9+
### Fixed
10+
- proxy will no correctly handle paths that end with a / at the end.
11+
712
## 1.11.0 - 2020-08-31
813

914
### Added

app/controllers/Application.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ class Application @Inject() (files: FileService, collections: CollectionService,
3131
* @param path the path minus the slash
3232
* @return moved permanently to path without /
3333
*/
34-
def untrail(path: String) = Action {
35-
MovedPermanently("/" + path)
34+
def untrail(path: String) = Action { implicit request =>
35+
MovedPermanently(s"${Utils.baseUrl(request, false)}/${path}")
3636
}
3737

3838
def swaggerUI = Action { implicit request =>

app/controllers/Utils.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ object Utils {
1414
* Return base url given a request. This will add http or https to the front, for example
1515
* https://localhost:9443 will be returned if it is using https.
1616
*/
17-
def baseUrl(request: Request[Any]) = {
18-
routes.Files.list().absoluteURL(https(request))(request).replace("/files", "")
17+
def baseUrl(request: Request[Any], absolute: Boolean = true) = {
18+
if (absolute) {
19+
routes.Files.list().absoluteURL(https(request))(request).replace("/files", "")
20+
} else {
21+
routes.Files.list().url.replace("/files", "")
22+
}
1923
}
2024

2125
/**

conf/routes

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77

88
#OPTIONS /*path @controllers.Application.options(path)
99
OPTIONS /*path api.ApiHelp.options(path)
10+
11+
# operations are applied in this order, to prevent untrail from removing
12+
# the trailing / at the end of the /api/proxy calls it is placed before
13+
# the untrail call
14+
GET /api/proxy/:endpoint_key @api.Proxy.get(endpoint_key: String, pathSuffix: String = null)
15+
GET /api/proxy/:endpoint_key/ @api.Proxy.get(endpoint_key: String, pathSuffix: String = "")
16+
GET /api/proxy/:endpoint_key/*pathSuffix @api.Proxy.get(endpoint_key: String, pathSuffix: String)
1017
GET /*path/ @controllers.Application.untrail(path: String)
1118

1219
# ----------------------------------------------------------------------
@@ -859,17 +866,14 @@ DELETE /api/standardvocab/:id
859866
# PROXY API
860867
# ----------------------------------------------------------------------
861868

862-
GET /api/proxy/:endpoint_key @api.Proxy.get(endpoint_key: String, pathSuffix: String = null)
863-
GET /api/proxy/:endpoint_key/ @api.Proxy.get(endpoint_key: String, pathSuffix: String = null)
864-
GET /api/proxy/:endpoint_key/*pathSuffix @api.Proxy.get(endpoint_key: String, pathSuffix: String)
865869
POST /api/proxy/:endpoint_key @api.Proxy.post(endpoint_key: String, pathSuffix: String = null)
866-
POST /api/proxy/:endpoint_key/ @api.Proxy.post(endpoint_key: String, pathSuffix: String = null)
870+
POST /api/proxy/:endpoint_key/ @api.Proxy.post(endpoint_key: String, pathSuffix: String = "")
867871
POST /api/proxy/:endpoint_key/*pathSuffix @api.Proxy.post(endpoint_key: String, pathSuffix: String)
868872
PUT /api/proxy/:endpoint_key @api.Proxy.put(endpoint_key: String, pathSuffix: String = null)
869-
PUT /api/proxy/:endpoint_key/ @api.Proxy.put(endpoint_key: String, pathSuffix: String = null)
873+
PUT /api/proxy/:endpoint_key/ @api.Proxy.put(endpoint_key: String, pathSuffix: String = "")
870874
PUT /api/proxy/:endpoint_key/*pathSuffix @api.Proxy.put(endpoint_key: String, pathSuffix: String)
871875
DELETE /api/proxy/:endpoint_key @api.Proxy.delete(endpoint_key: String, pathSuffix: String = null)
872-
DELETE /api/proxy/:endpoint_key/ @api.Proxy.delete(endpoint_key: String, pathSuffix: String = null)
876+
DELETE /api/proxy/:endpoint_key/ @api.Proxy.delete(endpoint_key: String, pathSuffix: String = "")
873877
DELETE /api/proxy/:endpoint_key/*pathSuffix @api.Proxy.delete(endpoint_key: String, pathSuffix: String)
874878

875879
# ----------------------------------------------------------------------

public/jsonld/contexts/extractors.jsonld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"extractor": "https://clowder.ncsa.illinois.edu/contexts/extractor#",
44
"id":"extractor/internal_id",
55
"name": {"@id": "extractor:extractor/id", "@type": "@id"},
6-
"version": "extractor:version"
6+
"version": "extractor:version",
77
"created_at": {
88
"@id": "extractor:updated",
99
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
@@ -19,4 +19,4 @@
1919
"libraries": "extractor:libraries",
2020
"bibtex": "extractor:bibtex",
2121
"dependencies":"extractor:dependencies"
22-
}
22+
}

public/jsonld/contexts/metadata.jsonld

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@
2020
"extractor": "cat:extractor",
2121
"content": {
2222
"@id": "https://clowder.ncsa.illinois.edu/metadata#content"
23-
}
23+
},
2424
"attached_to": "https://clowder.ncsa.illinois.edu/metadata/attachedTo",
2525
"resource_type": "https://clowder.ncsa.illinois.edu/resource/type",
2626
"url": "https://clowder.ncsa.illinois.edu/resource"
2727
}
2828
}
29-
30-

0 commit comments

Comments
 (0)