* Simple Boot REST application and example * BAEL-509 - Removed extra duplicate ant matcher * Example and Unit Tests * documentation * BAEL-1085 - changes per PR code review and document review - altered integration to unit test - all's good * BAEL-1085 - Renamed unit tests and added both to pom.xml * IntelliJ formatter * REVERT - Had removed a duplicate ant matcher from BAEL-509 - this was the incorrect process - reverting now, article has been corrected, but will issue a seperate PR for this
38 lines
1.5 KiB
Java
38 lines
1.5 KiB
Java
package com.baeldung.controllers;
|
|
|
|
import com.baeldung.services.ExampleService;
|
|
import com.baeldung.transfer.ResponseTransfer;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import com.baeldung.transfer.LoginForm;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
@Controller
|
|
@RequestMapping("/post")
|
|
public class ExamplePostController {
|
|
|
|
private static Logger log = LoggerFactory.getLogger(ExamplePostController.class);
|
|
|
|
@Autowired ExampleService exampleService;
|
|
|
|
@PostMapping("/request")
|
|
public ResponseEntity postController(@RequestBody LoginForm loginForm) {
|
|
log.debug("POST received - serializing LoginForm: " + loginForm.getPassword() + " " + loginForm.getUsername());
|
|
exampleService.fakeAuthenticate(loginForm);
|
|
return ResponseEntity.ok(HttpStatus.OK);
|
|
}
|
|
|
|
@PostMapping("/response")
|
|
@ResponseBody
|
|
public ResponseTransfer postResponseController(@RequestBody LoginForm loginForm) {
|
|
log.debug("POST received - serializing LoginForm: " + loginForm.getPassword() + " " + loginForm.getUsername());
|
|
return new ResponseTransfer("Thanks For Posting!!!");
|
|
}
|
|
} |