Api utils; Ping endpoint
This commit is contained in:
parent
29a9d1dfaa
commit
f57e235b39
@ -5,7 +5,6 @@ import com.displaynone.acss.components.acs.models.gate.service.GateService;
|
||||
import com.displaynone.acss.components.acs.models.visit.VisitModel;
|
||||
import com.displaynone.acss.components.acs.models.visit.service.VisitService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -13,7 +12,6 @@ import org.springframework.stereotype.Component;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class ACSComponent {
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.displaynone.acss.controllers.utils;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/utils")
|
||||
@RequiredArgsConstructor
|
||||
public class UtilsController {
|
||||
@GetMapping("/ping")
|
||||
public ResponseEntity<String> ping() {
|
||||
return ResponseEntity.ok("Pong");
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.security.authentication.InternalAuthenticationServiceException;
|
||||
import org.springframework.web.HttpMediaTypeNotSupportedException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
@ -50,7 +51,7 @@ public class GlobalExceptionHandler {
|
||||
}
|
||||
|
||||
@ExceptionHandler(HttpMessageNotReadableException.class)
|
||||
public ResponseEntity<ErrorResponsePayload> handleHttpMessageNotReadableException(InvalidFormatException e, WebRequest request) {
|
||||
public ResponseEntity<ErrorResponsePayload> handleHttpMessageNotReadableException(HttpMessageNotReadableException e, WebRequest request) {
|
||||
return buildErrorResponse(e, HttpStatus.BAD_REQUEST, "Bad request payload format: failed to parse");
|
||||
}
|
||||
|
||||
@ -81,4 +82,9 @@ public class GlobalExceptionHandler {
|
||||
public ResponseEntity<ErrorResponsePayload> handleForbiddenHTTPException(ForbiddenHTTPException e, WebRequest request) {
|
||||
return buildErrorResponse(e, HttpStatus.FORBIDDEN, null);
|
||||
}
|
||||
|
||||
@ExceptionHandler(HttpMediaTypeNotSupportedException.class)
|
||||
public ResponseEntity<ErrorResponsePayload> handleHttpMediaTypeNotSupportedException(HttpMediaTypeNotSupportedException e, WebRequest request) {
|
||||
return buildErrorResponse(e, HttpStatus.BAD_REQUEST, null);
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ public class WebSecurityConfig {
|
||||
|
||||
.authorizeHttpRequests(authorizeRequests ->
|
||||
authorizeRequests
|
||||
.requestMatchers("/api/utils/**").permitAll()
|
||||
.requestMatchers("/api/auth/**").permitAll()
|
||||
.requestMatchers("/api/users/login/**").hasAuthority("ROLE_ADMIN")
|
||||
.requestMatchers("/api/acs/visits/login/**").hasAuthority("ROLE_ADMIN")
|
||||
|
Loading…
x
Reference in New Issue
Block a user