Class PaymentController
java.lang.Object
io.github.ravocode.avoonce.sample.PaymentController
Sample REST controller demonstrating selective idempotency protection for payment endpoints.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classIncoming payment request payload used by the controller.static classResponse payload returned after processing a payment request. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of processed payment requests seen by this sample controller.org.springframework.http.ResponseEntity<PaymentController.PaymentResponse> Protected endpoint: annotated withIdempotent.org.springframework.http.ResponseEntity<PaymentController.PaymentResponse> Unprotected endpoint: NOT annotated withIdempotent.org.springframework.http.ResponseEntity<Void> Resets the sample controller's processing counter.
-
Constructor Details
-
PaymentController
public PaymentController()
-
-
Method Details
-
processPayment
@PostMapping @Idempotent public org.springframework.http.ResponseEntity<PaymentController.PaymentResponse> processPayment(@RequestBody PaymentController.PaymentRequest request) Protected endpoint: annotated withIdempotent. Deduplicated and cached in both GLOBAL mode and ANNOTATION mode.- Parameters:
request- the payment request payload- Returns:
- a response entity containing the processing outcome
-
processUnprotectedPayment
@PostMapping("/unprotected") public org.springframework.http.ResponseEntity<PaymentController.PaymentResponse> processUnprotectedPayment(@RequestBody PaymentController.PaymentRequest request) Unprotected endpoint: NOT annotated withIdempotent. In ANNOTATION mode, requests to this endpoint bypass the idempotency filter.- Parameters:
request- the payment request payload- Returns:
- a response entity containing the processing outcome
-
getProcessCount
@GetMapping("/count") public int getProcessCount()Returns the number of processed payment requests seen by this sample controller.- Returns:
- the current process count
-
resetCount
Resets the sample controller's processing counter.- Returns:
- an empty success response
-