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