package com.eactive.httpmockserver.client.controller;

import com.eactive.httpmockserver.server.entity.Server;
import com.eactive.httpmockserver.server.entity.ServerRepository;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Controller
public class ApiClientPageController {

    private final ServerRepository serverRepository;

    public ApiClientPageController(ServerRepository serverRepository) {
        this.serverRepository = serverRepository;
    }

    @GetMapping("/mgmt/api_tester.do")
    public String testView(ModelMap model) {

        List<Server> servers = serverRepository.findAllByEnabledIs(true);
        model.addAttribute("servers", servers);

        return "page/tester/apiTester";
    }

}
