package org.minager.serverhandling;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/server")
public class ServerHandlingController {
	@Autowired
	private ServerHandlingService serverHandlingService;
	
	@GetMapping("/status")
	public int getStatus() {
		return serverHandlingService.getStatus();
	}
	
	@PostMapping("/start")
	public void startServer(final HttpServletResponse pResponse) throws IOException {
		serverHandlingService.startServer(pResponse);
	}
	
	@PostMapping("/stop")
	public void stopServer(final HttpServletResponse pResponse) throws IOException {
		serverHandlingService.stopServer(pResponse);
	}
	
	@PostMapping("/restart")
	public void restartServer(final HttpServletResponse pResponse) throws IOException {
		serverHandlingService.restartServer(pResponse);
	}
}
