package click.kamil.examples.statemachine.layered.web;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/commands")
public class GenericCommandController {

    private final CommandGateway commandGateway;

    public GenericCommandController(CommandGateway commandGateway) {
        this.commandGateway = commandGateway;
    }

    @PostMapping("/{commandKey}")
    public void execute(@PathVariable String commandKey) {
        commandGateway.executeViaMapper(commandKey);
    }
}
