From 7f6aa658c287308ebc1ac578e663d2aea5ab1db7 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 24 Mar 2021 19:10:37 +0300 Subject: Fix url logging in HttpMediaTypeNotAcceptableException handler --- src/main/java/com/juick/www/api/Index.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/juick/www') diff --git a/src/main/java/com/juick/www/api/Index.java b/src/main/java/com/juick/www/api/Index.java index 2d71683e..46aa65b5 100644 --- a/src/main/java/com/juick/www/api/Index.java +++ b/src/main/java/com/juick/www/api/Index.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2020, Juick + * Copyright (C) 2008-2021, Juick * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -41,16 +41,19 @@ import java.net.URI; @RestController public class Index { private static final Logger logger = LoggerFactory.getLogger("API"); + @Hidden @RequestMapping(value = { "/api/", "/ws/" }, method = RequestMethod.GET) public ResponseEntity description() { URI redirectUri = ServletUriComponentsBuilder.fromCurrentRequestUri().path("/swagger-ui.html").build().toUri(); return ResponseEntity.status(HttpStatus.MOVED_PERMANENTLY).location(redirectUri).build(); } + @ExceptionHandler(HttpMediaTypeNotAcceptableException.class) public ResponseEntity invalidMediaType(final HttpMediaTypeNotAcceptableException exception, final NativeWebRequest request) { - logger.info("Media type not resolved ({}) for url: {}", request.getHeaderValues("Accept"), ServletUriComponentsBuilder.fromCurrentRequestUri()); + logger.info("Media type not resolved ({}) for url: {}", request.getHeaderValues("Accept"), + ServletUriComponentsBuilder.fromCurrentRequestUri().build().toUriString()); return ResponseEntity.badRequest().body("Invalid media type"); } } -- cgit v1.2.3