Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add trailing slashes to request paths #485

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ Lets say you want to create two pages on paths `/events/example/page-1` and on `

```java
@Controller
@RequestMapping(value = "/events/example")
@RequestMapping({"/events/example","/events/example/"})
public class MyController {

@RequestMapping(value= "/page-1")
@RequestMapping({"/page-1","/page-1/"})
public String handlePageOne() { return "page 1"; }

@RequestMapping(value= "/page-2")
@RequestMapping({"/page-2","/page-2/"})
public String handlePageTwo() { return "page 2"; }
}
```
Expand All @@ -46,10 +46,10 @@ Or you could uses a `@PathVariable` which makes a part of the Path variable whic

```java
@Controller
@RequestMapping(value = "/events/example")
@RequestMapping({"/events/example","/events/example/"})
public class MyController {

@RequestMapping(value= "/{page}")
@RequestMapping({"/{page}","/{page}/"})
public String handleBothPages(@PathVariable String page) { return page; }
}
```
Expand Down
15 changes: 0 additions & 15 deletions src/main/java/ch/wisv/events/WebConfiguration.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* DashboardCustomerController class.
*/
@Controller
@RequestMapping(value = "/administrator/customers")
@RequestMapping({"/administrator/customers","/administrator/customers/"})
@PreAuthorize("hasRole('ADMIN')")
public class DashboardCustomerController extends DashboardController {

Expand Down Expand Up @@ -49,7 +49,7 @@ public DashboardCustomerController(CustomerService customerService, TicketServic
*
* @return path to customers index template
*/
@GetMapping()
@GetMapping({"","/"})
public String index(Model model) {
model.addAttribute(OBJ_CUSTOMERS, customerService.getAllCustomers());

Expand All @@ -66,7 +66,7 @@ public String index(Model model) {
*
* @return path to the customer edit template
*/
@GetMapping("/view/{key}")
@GetMapping({"/view/{key}","/view/{key}/"})
public String view(Model model, RedirectAttributes redirect, @PathVariable String key) {
try {
Customer customer = customerService.getByKey(key);
Expand All @@ -88,7 +88,7 @@ public String view(Model model, RedirectAttributes redirect, @PathVariable Strin
*
* @return path to customer create template
*/
@GetMapping("/create")
@GetMapping({"/create","/create/"})
public String create(Model model) {
if (!model.containsAttribute(OBJ_CUSTOMER)) {
model.addAttribute(OBJ_CUSTOMER, new Customer());
Expand All @@ -106,7 +106,7 @@ public String create(Model model) {
*
* @return redirect
*/
@PostMapping("/create")
@PostMapping({"/create","/create/"})
public String create(RedirectAttributes redirect, @ModelAttribute Customer model) {
try {
customerService.create(model);
Expand All @@ -132,7 +132,7 @@ public String create(RedirectAttributes redirect, @ModelAttribute Customer model
*
* @return path to the customer edit template
*/
@GetMapping("/edit/{key}")
@GetMapping({"/edit/{key}","/edit/{key}/"})
public String edit(Model model, RedirectAttributes redirect, @PathVariable String key) {
try {
Customer customer = customerService.getByKey(key);
Expand All @@ -159,7 +159,7 @@ public String edit(Model model, RedirectAttributes redirect, @PathVariable Strin
*
* @return redirect
*/
@PostMapping("/edit/{key}")
@PostMapping({"/edit/{key}","/edit/{key}/"})
public String edit(RedirectAttributes redirect, @ModelAttribute Customer customer, @PathVariable String key) {
try {
customer.setKey(key);
Expand All @@ -185,7 +185,7 @@ public String edit(RedirectAttributes redirect, @ModelAttribute Customer custome
*
* @return redirect
*/
@GetMapping("/delete/{key}")
@GetMapping({"/delete/{key}","/delete/{key}/"})
public String delete(RedirectAttributes redirect, @PathVariable String key) {
try {
Customer customer = customerService.getByKey(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* DashboardEventController class.
*/
@Controller
@RequestMapping(value = "/administrator/events")
@RequestMapping({"/administrator/events","/administrator/events/"})
@PreAuthorize("hasRole('ADMIN')")
public class DashboardEventController extends DashboardController {

Expand Down Expand Up @@ -80,7 +80,7 @@ public DashboardEventController(
*
* @return path to Thymeleaf template
*/
@GetMapping()
@GetMapping({"","/"})
public String index(Model model) {
model.addAttribute(OBJ_EVENTS, eventService.getAll());

Expand All @@ -96,7 +96,7 @@ public String index(Model model) {
*
* @return String
*/
@GetMapping("/view/{key}")
@GetMapping({"/view/{key}","/view/{key}/"})
public String view(Model model, RedirectAttributes redirect, @PathVariable String key) {
try {
model.addAttribute(OBJ_EVENT, eventService.getByKey(key));
Expand All @@ -116,7 +116,7 @@ public String view(Model model, RedirectAttributes redirect, @PathVariable Strin
*
* @return path to Thymeleaf template
*/
@GetMapping("/create")
@GetMapping({"/create","/create/"})
public String create(Model model) {
if (!model.containsAttribute(OBJ_EVENT)) {
model.addAttribute(OBJ_EVENT, new Event());
Expand All @@ -134,7 +134,7 @@ public String create(Model model) {
*
* @return redirect
*/
@PostMapping("/create")
@PostMapping({"/create","/create/"})
public String create(RedirectAttributes redirect, @ModelAttribute Event event, @RequestParam("file") MultipartFile file) {
try {
if (file.getSize() > 0) {
Expand Down Expand Up @@ -168,7 +168,7 @@ public String create(RedirectAttributes redirect, @ModelAttribute Event event, @
*
* @return path to Thymeleaf template
*/
@GetMapping("/edit/{key}")
@GetMapping({"/edit/{key}","/edit/{key}/"})
public String edit(Model model, RedirectAttributes redirect, @PathVariable String key) {
try {
if (!model.containsAttribute(OBJ_EVENT)) {
Expand All @@ -193,7 +193,7 @@ public String edit(Model model, RedirectAttributes redirect, @PathVariable Strin
*
* @return redirect
*/
@PostMapping("/edit/{key}")
@PostMapping({"/edit/{key}","/edit/{key}/"})
public String update(
RedirectAttributes redirect,
@ModelAttribute Event event,
Expand Down Expand Up @@ -235,7 +235,7 @@ public String update(
*
* @return String
*/
@GetMapping("/overview/{key}")
@GetMapping({"/overview/{key}","/overview/{key}/"})
public String overview(Model model, RedirectAttributes redirect, @PathVariable String key) {
try {
Event event = eventService.getByKey(key);
Expand Down Expand Up @@ -299,7 +299,7 @@ public HttpEntity<? extends Object> csvExport(@PathVariable String key) {
*
* @return redirect
*/
@GetMapping("/delete/{key}")
@GetMapping({"/delete/{key}","/delete/{key}/"})
public String deleteEvent(RedirectAttributes redirect, @PathVariable String key) {
try {
Event event = eventService.getByKey(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* DashboardController.
*/
@Controller
@RequestMapping(value = "/administrator")
@RequestMapping({"/administrator","/administrator/"})
@PreAuthorize("hasRole('ADMIN')")
public class DashboardIndexController extends DashboardController {

Expand Down Expand Up @@ -57,7 +57,7 @@ public DashboardIndexController(
*
* @return path to Thymeleaf template
*/
@GetMapping()
@GetMapping({"","/"})
public String index(Model model) {
List<Event> upcomingEvents = this.determineUpcomingEvents();
LocalDateTime CurrentBoardStartYear = this.getCurrentBoardStartDate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* DashboardOrderController class.
*/
@Controller
@RequestMapping(value = "/administrator/orders")
@RequestMapping({"/administrator/orders","/administrator/orders/"})
@PreAuthorize("hasRole('ADMIN')")
public class DashboardOrderController extends DashboardController {

Expand Down Expand Up @@ -57,7 +57,7 @@ public DashboardOrderController(
*
* @return String
*/
@GetMapping()
@GetMapping({"","/"})
public String index(Model model) {
model.addAttribute(OBJ_ORDERS, this.orderService.getLimitedOrders());

Expand All @@ -73,7 +73,7 @@ public String index(Model model) {
*
* @return String
*/
@GetMapping("/view/{key}")
@GetMapping({"/view/{key}","/view/{key}/"})
public String edit(Model model, RedirectAttributes redirect, @PathVariable String key) {
try {
Order order = orderService.getByReference(key);
Expand All @@ -95,7 +95,7 @@ public String edit(Model model, RedirectAttributes redirect, @PathVariable Strin
*
* @return String
*/
@GetMapping("/delete/{key}")
@GetMapping({"/delete/{key}","/delete/{key}/"})
public String delete(RedirectAttributes redirect, @PathVariable String key) {
try {
Order order = orderService.getByReference(key);
Expand All @@ -117,7 +117,7 @@ public String delete(RedirectAttributes redirect, @PathVariable String key) {
*
* @return String
*/
@GetMapping("/resend-confirmation-mail/{key}")
@GetMapping({"/resend-confirmation-mail/{key}","/resend-confirmation-mail/{key}/"})
public String resendConfirmationMail(RedirectAttributes redirect, @PathVariable String key) {
try {
Order order = orderService.getByReference(key);
Expand All @@ -140,7 +140,7 @@ public String resendConfirmationMail(RedirectAttributes redirect, @PathVariable
*
* @return String
*/
@GetMapping("/approve/{key}/{payment}")
@GetMapping({"/approve/{key}/{payment}","/approve/{key}/{payment}/"})
public String approve(RedirectAttributes redirect, @PathVariable String key, @PathVariable PaymentMethod payment) {
try {
Order order = orderService.getByReference(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* DashboardProductController.
*/
@Controller
@RequestMapping("/administrator/products")
@RequestMapping({"/administrator/products","/administrator/products/"})
@PreAuthorize("hasRole('ADMIN')")
public class DashboardProductController extends DashboardController {

Expand Down Expand Up @@ -74,7 +74,7 @@ public String index(Model model) {
*
* @return String
*/
@GetMapping("/view/{key}")
@GetMapping({"/view/{key}","/view/{key}"})
public String view(Model model, RedirectAttributes redirect, @PathVariable String key) {
try {
model.addAttribute(OBJ_PRODUCT, productService.getByKey(key));
Expand All @@ -94,7 +94,7 @@ public String view(Model model, RedirectAttributes redirect, @PathVariable Strin
*
* @return thymeleaf template path
*/
@GetMapping("/create")
@GetMapping({"/create","/create/"})
public String create(Model model) {
if (!model.containsAttribute(OBJ_PRODUCT)) {
model.addAttribute(OBJ_PRODUCT, new Product());
Expand All @@ -111,7 +111,7 @@ public String create(Model model) {
*
* @return redirect
*/
@PostMapping("/create")
@PostMapping({"/create","/create/"})
public String create(RedirectAttributes redirect, @ModelAttribute Product product) {
try {
if (product.getRedirectUrl() != null && product.getRedirectUrl().length() == 0){
Expand Down Expand Up @@ -140,7 +140,7 @@ public String create(RedirectAttributes redirect, @ModelAttribute Product produc
*
* @return thymeleaf template path
*/
@GetMapping("/edit/{key}")
@GetMapping({"/edit/{key}","/edit/{key}/"})
public String edit(Model model, RedirectAttributes redirect, @PathVariable String key) {
try {
if (!model.containsAttribute(OBJ_PRODUCT)) {
Expand All @@ -164,7 +164,7 @@ public String edit(Model model, RedirectAttributes redirect, @PathVariable Strin
*
* @return String
*/
@PostMapping("/edit/{key}")
@PostMapping({"/edit/{key}","/edit/{key}/"})
public String update(RedirectAttributes redirect, @ModelAttribute Product product, @PathVariable String key) {
try {
product.setKey(key);
Expand Down Expand Up @@ -193,7 +193,7 @@ public String update(RedirectAttributes redirect, @ModelAttribute Product produc
*
* @return String
*/
@GetMapping("/overview/{key}")
@GetMapping({"/overview/{key}","/overview/{key}/"})
public String overview(Model model, RedirectAttributes redirect, @PathVariable String key) {
try {
Product product = productService.getByKey(key);
Expand All @@ -217,7 +217,7 @@ public String overview(Model model, RedirectAttributes redirect, @PathVariable S
*
* @return redirect
*/
@GetMapping("/delete/{key}")
@GetMapping({"/delete/{key}","/delete/{key}/"})
public String delete(RedirectAttributes redirectAttributes, @PathVariable String key) {
try {
Product product = productService.getByKey(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* DashboardSalesExportController class.
*/
@Controller
@RequestMapping("/administrator/salesexport")
@RequestMapping({"/administrator/salesexport","/administrator/salesexport/"})
@PreAuthorize("hasRole('ADMIN')")
public class DashboardSalesExportController extends DashboardController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/administrator/tasks")
@RequestMapping({"/administrator/tasks","/administrator/tasks/"})
@PreAuthorize("hasRole('ADMIN')")
public class DashboardTasksController extends DashboardController {

Expand All @@ -33,7 +33,7 @@ public DashboardTasksController(WebhookTaskService webhookTaskService) {
*
* @return path to Thymeleaf template location
*/
@GetMapping()
@GetMapping({"","/"})
public String index(Model model) {
model.addAttribute(OBJ_TASKS, webhookTaskService.getAll());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* DashboardWebhookController class.
*/
@Controller
@RequestMapping("/administrator/treasurer")
@RequestMapping({"/administrator/treasurer","/administrator/treasurer/"})
@PreAuthorize("hasRole('ADMIN')")
public class DashboardTreasurerController extends DashboardController {

Expand Down
Loading
Loading