Endpoints async for posting mail and landingpage
This commit is contained in:
parent
6c91e7dc8a
commit
36fcb58caa
@ -5,11 +5,16 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.owasp.webwolf.user.UserRepository;
|
||||
import org.owasp.webwolf.user.WebGoatUser;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* @author nbaars
|
||||
@ -37,13 +42,16 @@ public class MailboxController {
|
||||
}
|
||||
|
||||
@PostMapping(value = "/mail")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public void sendEmail(@RequestBody Email email) {
|
||||
if (userRepository.findByUsername(email.getRecipient()) != null) {
|
||||
mailboxRepository.save(email);
|
||||
} else {
|
||||
log.trace("Mail received for unknown user: {}", email.getRecipient());
|
||||
}
|
||||
public Callable<ResponseEntity<?>> sendEmail(@RequestBody Email email) {
|
||||
return () -> {
|
||||
if (userRepository.findByUsername(email.getRecipient()) != null) {
|
||||
mailboxRepository.save(email);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).build();
|
||||
} else {
|
||||
log.trace("Mail received for unknown user: {}", email.getRecipient());
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,23 +2,25 @@ package org.owasp.webwolf.requests;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@Controller
|
||||
@Slf4j
|
||||
@RequestMapping("/landing/**")
|
||||
public class LandingPage {
|
||||
|
||||
@RequestMapping(method = { RequestMethod.POST, RequestMethod.GET, RequestMethod.DELETE, RequestMethod.PATCH, RequestMethod.PUT})
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public void ok(HttpServletRequest request) {
|
||||
log.trace("Incoming request for: {}", request.getRequestURL());
|
||||
@RequestMapping(method = {RequestMethod.POST, RequestMethod.GET, RequestMethod.DELETE, RequestMethod.PATCH, RequestMethod.PUT})
|
||||
public Callable<ResponseEntity<?>> ok(HttpServletRequest request) {
|
||||
return () -> {
|
||||
log.trace("Incoming request for: {}", request.getRequestURL());
|
||||
return ResponseEntity.ok().build();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user