49 lines
1.2 KiB
Java
49 lines
1.2 KiB
Java
package ru.pdguard.api;
|
|
|
|
import jakarta.ws.rs.GET;
|
|
import jakarta.ws.rs.POST;
|
|
import jakarta.ws.rs.Path;
|
|
import jakarta.ws.rs.Produces;
|
|
import jakarta.ws.rs.core.MediaType;
|
|
import ru.pdguard.config.SystemPolicy;
|
|
import ru.pdguard.config.SystemsConfig;
|
|
import ru.pdguard.detect.RuleRegistry;
|
|
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/** Просмотр действующих настроек и принудительное их перечитывание. */
|
|
@Path("/admin")
|
|
public class AdminResource {
|
|
|
|
private final SystemsConfig systems;
|
|
private final RuleRegistry registry;
|
|
|
|
public AdminResource(SystemsConfig systems, RuleRegistry registry) {
|
|
this.systems = systems;
|
|
this.registry = registry;
|
|
}
|
|
|
|
@GET
|
|
@Path("/config")
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
public Map<String, SystemPolicy> config() {
|
|
return systems.current();
|
|
}
|
|
|
|
@GET
|
|
@Path("/types")
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
public List<String> types() {
|
|
return registry.knownTypes();
|
|
}
|
|
|
|
@POST
|
|
@Path("/reload")
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
public Map<String, SystemPolicy> reload() {
|
|
systems.reload();
|
|
return systems.current();
|
|
}
|
|
}
|