Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example;
- import org.springframework.boot.SpringApplication;
- import org.springframework.boot.autoconfigure.SpringBootApplication;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RestController;
- import org.springframework.http.ResponseEntity;
- @SpringBootApplication
- @RestController
- public class App {
- public static class MyEntity {
- private long id;
- private String value;
- public MyEntity() { }
- public MyEntity(long id, String value) { this.id = id; this.value = value; }
- public long getId() { return id; }
- public String getValue() { return value; }
- }
- @PostMapping("/api/myentity/{id}/clone")
- public ResponseEntity<MyEntity> cloneMyEntity(@PathVariable("id") long id) {
- return ResponseEntity.ok(new MyEntity(id + 1, "my entity"));
- }
- public static void main(String[] args) {
- SpringApplication.run(App.class, args);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment