Skip to content

Commit

Permalink
Add simple HeartbeatController
Browse files Browse the repository at this point in the history
  • Loading branch information
svencc committed Nov 27, 2024
1 parent 047f1f4 commit 4c6f217
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.recom.api;

import com.recom.api.commons.HttpCommons;
import com.recom.dto.authentication.AccountRequestDto;
import com.recom.dto.authentication.AuthenticationRequestDto;
import com.recom.dto.authentication.AuthenticationResponseDto;
import com.recom.service.AuthenticationService;
import com.recom.service.ReforgerPayloadParserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.CacheControl;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@Tag(name = "Heartbeat")
@RequestMapping("/api/v1/heartbeat")
public class HeartbeatController {

@Operation(
summary = "Heartbeat",
description = "Sends an is-alive message."
)
@ApiResponses(value = {
@ApiResponse(responseCode = HttpCommons.OK_CODE, description = HttpCommons.OK),
@ApiResponse(responseCode = HttpCommons.UNAUTHORIZED_CODE, description = HttpCommons.UNAUTHORIZED, content = {@Content()}),
})
@PostMapping(path = "/form", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ResponseEntity<Void> heartbeatForm(
@RequestParam(required = true)
@NonNull final Map<String, String> payload
) {
log.debug("Requested POST /api/v1/authenticate (FORM)");

return heartbeatJSON();
}

@Operation(
summary = "Heartbeat",
description = "Sends an is-alive message."
)
@ApiResponses(value = {
@ApiResponse(responseCode = HttpCommons.OK_CODE, description = HttpCommons.OK),
@ApiResponse(responseCode = HttpCommons.UNAUTHORIZED_CODE, description = HttpCommons.UNAUTHORIZED, content = {@Content()}),
})
@PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Void> heartbeatJSON() {
log.debug("Requested POST /api/v1/heartbeat (JSON)");

return ResponseEntity.status(HttpStatus.OK)
.cacheControl(CacheControl.noCache())
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ logging.level.com.recom.service.gameMap.TopographyMapDataService=INFO
logging.level.com.recom.service.dbcached=INFO
logging.level.com.recom.persistence.dbcached=DEBUG

logging.level.com.recom.api.AuthenticationController=DEBUG
logging.level.com.recom.api.HeartbeatController=DEBUG
#logging.level.org.hibernate.SQL=DEBUG
#logging.level.org.hibernate.com.jdbc.bind=TRACE
logging.level.com.vladmihalcea.hibernate.type.util.LogUtils=DEBUG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ recom.ehcache-base-dir=${recom.data-base-dir}/ehcache
recom.ehcache-appcache-base-dir=${recom.data-base-dir}/ehcache_appcache

recom.security.jwt-issuer=RECOM DEV Backend
recom.security.jwt-expiration-time=60m
recom.security.jwt-expiration-time=60s
recom.security.key-path=${recom.data-base-dir}/RECOMKey

recom.async.core-pool-size=1
Expand Down

0 comments on commit 4c6f217

Please sign in to comment.