File tree Expand file tree Collapse file tree
customer-core/src/main/java/com/lakesidemutual/customercore/interfaces Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .lakesidemutual .customercore .interfaces ;
2+
3+ import org .springframework .http .HttpStatus ;
4+ import org .springframework .http .ResponseEntity ;
5+ import org .springframework .web .bind .annotation .*;
6+
7+ import java .net .URI ;
8+
9+ import static org .springframework .hateoas .server .mvc .WebMvcLinkBuilder .linkTo ;
10+ import static org .springframework .hateoas .server .mvc .WebMvcLinkBuilder .methodOn ;
11+
12+ /**
13+ * This controller demonstrates the use of a 301 Moved Permanently response to redirect requests to a new URI.
14+ *
15+ * See the <a href="https://interface-refactoring.github.io/refactorings/renameendpoint">Rename Endpoint</a> refactoring for more information.
16+ */
17+ @ RestController
18+ @ RequestMapping (path = "getCustomers" )
19+ public class OldCustomerInformationHolder {
20+
21+ /**
22+ * Handles GET requests for customer information.
23+ *
24+ * @param ids The customer IDs.
25+ * @param fields The fields to be included in the response (optional).
26+ * @return A ResponseEntity with a status of 301 Moved Permanently and the location header set to the new URI.
27+ */
28+ @ GetMapping (value = "/{ids}" )
29+ @ ResponseBody
30+ public ResponseEntity getCustomer (
31+ @ PathVariable String ids ,
32+ @ RequestParam (value = "fields" , required = false , defaultValue = "" ) String fields ) {
33+ URI movedTo = linkTo (methodOn (CustomerInformationHolder .class ).getCustomer (ids , fields )).toUri ();
34+ return ResponseEntity
35+ .status (HttpStatus .MOVED_PERMANENTLY )
36+ .location (movedTo )
37+ .build ();
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments