Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gerrit Alexander Simon Evers
Verteilte Systeme Projekt
Commits
d1f7df70
Commit
d1f7df70
authored
Jan 31, 2021
by
Andre Blanke
Browse files
Add temporary debug GET mapping at /ping
parent
20d7272b
Changes
2
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
d1f7df70
# IntelliJ IDEA
/PyCharm
project files
# IntelliJ IDEA project files
.idea/
.vagrant/
**/cockroach-data/
shortener/src/main/kotlin/xyz/upbshrt/shortener/controller/UrlShorteningController.kt
View file @
d1f7df70
...
...
@@ -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."
)
@GetMapping
(
"/ping"
)
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].
*/
@PostMapping
(
"/"
)
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
(
HttpStatus
.
FORBIDDEN
,
...
...
Write
Preview
Supports
Markdown
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