简体   繁体   中英

How to make a partial proxy using Spring Boot

The goal is to create a mock server for testing the Rest. I created the controller, made the mapping, and entities.

@RestController
public class GreetingController {
    private static final String template = "Hello, %s!";
    private final AtomicLong counter = new AtomicLong();

    @RequestMapping("/greeting")
    public GreetingResponse greeting(@RequestParam(value="name", defaultValue="World")
            String name) {
        return new GreetingResponse(counter.incrementAndGet(),
            String.format(template, name));
    }
}

How can I make a proxy so that all requests that are not equal to "/greeting" are passed to the other server unchanged and the response that the client would receive through our application?

Maybe response.sendRedirect? Or so

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM