Commit d1f7df70 authored by Andre Blanke's avatar Andre Blanke
Browse files

Add temporary debug GET mapping at /ping

parent 20d7272b
# IntelliJ IDEA/PyCharm project files
# IntelliJ IDEA project files
......@@ -26,6 +26,11 @@ class UrlShorteningController @Autowired constructor(private val repository: Url
private fun handleMalformedId(id: String): Nothing =
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "'$id' is not a valid id for linking to a URL.")
fun ping(): String {
return "pong";
* We use a URI instead of a URL here because Java has the ability to open InputStreams from URLs using
* URL.openStream. Because that ability exists, URLStreamHandlers are used for certain protocols and the
......@@ -49,9 +54,9 @@ class UrlShorteningController @Autowired constructor(private val repository: Url
* a provided [id] is malformed, or a mapped URL already exists for the supplied [id].
fun shortenUrl(@RequestParam("url") uri: URI,
fun shortenUrl(@RequestParam("url") uri: URI,
@Pattern(regexp = "[a-zA-Z0-9]+")
@RequestParam(required = false) id: String?): ResponseEntity<String> {
@RequestParam(required = false) id: String?): ResponseEntity<String> {
if (!allowedUrlProtocols.contains(uri.scheme))
throw ResponseStatusException(
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment