59 lines
1.6 KiB
Java
59 lines
1.6 KiB
Java
package tk.antoine_roux.wiki;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import tk.antoine_roux.wiki.annotation.ApiPrefix;
|
|
import tk.antoine_roux.wiki.annotation.ApiVersion;
|
|
|
|
import java.util.Map;
|
|
import java.util.TreeMap;
|
|
|
|
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
|
import static tk.antoine_roux.wiki.Constant.*;
|
|
|
|
@RestController
|
|
@ApiPrefix(API_PREFIX)
|
|
public class ControllerHandlers {
|
|
|
|
private RunnerRegistrar runnerRegistrar;
|
|
|
|
@Autowired
|
|
public ControllerHandlers(RunnerRegistrar runnerRegistrar) {
|
|
this.runnerRegistrar = runnerRegistrar;
|
|
}
|
|
|
|
/**
|
|
* add register new runners
|
|
*
|
|
* @param body
|
|
* @return
|
|
*/
|
|
@ResponseBody
|
|
@ApiVersion({API_VERSION})
|
|
@PostMapping(value = "/runners", produces = APPLICATION_JSON_VALUE)
|
|
public static ResponseEntity<String> addRunner(@RequestBody String body) {
|
|
System.out.println(body);
|
|
return ResponseEntity.ok(body);
|
|
}
|
|
|
|
/**
|
|
* hello test endpoint
|
|
*
|
|
* @return
|
|
*/
|
|
@ResponseBody
|
|
@GetMapping("/info")
|
|
public static ResponseEntity<TreeMap<String, String>> info() {
|
|
return ResponseEntity.ok(
|
|
// sort attribute by key name
|
|
new TreeMap<>(
|
|
Map.of(
|
|
"api-version", VERSION_PREFIX + API_VERSION,
|
|
"api-name", API_NAME
|
|
)
|
|
)
|
|
);
|
|
}
|
|
}
|