mirror of https://github.com/halo-dev/halo
Enable http trace list api
parent
aa398b2525
commit
5502463660
|
@ -0,0 +1,34 @@
|
||||||
|
package run.halo.app.controller.admin.api;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.boot.actuate.trace.http.HttpTrace;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import run.halo.app.service.TraceService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trace controller.
|
||||||
|
*
|
||||||
|
* @author johnniang
|
||||||
|
* @date 19-6-18
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/admin/traces")
|
||||||
|
public class TraceController {
|
||||||
|
|
||||||
|
private final TraceService traceService;
|
||||||
|
|
||||||
|
public TraceController(TraceService traceService) {
|
||||||
|
this.traceService = traceService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
@ApiOperation("Lists http traces")
|
||||||
|
public List<HttpTrace> listHttpTraces() {
|
||||||
|
return traceService.listHttpTraces();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package run.halo.app.model.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Http trace dto.
|
||||||
|
*
|
||||||
|
* @author johnniang
|
||||||
|
* @date 19-6-18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class HttpTraceDTO {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package run.halo.app.service;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.trace.http.HttpTrace;
|
||||||
|
import org.springframework.lang.NonNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trace service interface.
|
||||||
|
*
|
||||||
|
* @author johnniang
|
||||||
|
* @date 19-6-18
|
||||||
|
*/
|
||||||
|
public interface TraceService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all http traces.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
List<HttpTrace> listHttpTraces();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package run.halo.app.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.trace.http.HttpTrace;
|
||||||
|
import org.springframework.boot.actuate.trace.http.HttpTraceRepository;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageImpl;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
import run.halo.app.service.TraceService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author johnniang
|
||||||
|
* @date 19-6-18
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class TraceServiceImpl implements TraceService {
|
||||||
|
|
||||||
|
private final HttpTraceRepository httpTraceRepository;
|
||||||
|
|
||||||
|
public TraceServiceImpl(HttpTraceRepository httpTraceRepository) {
|
||||||
|
this.httpTraceRepository = httpTraceRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HttpTrace> listHttpTraces() {
|
||||||
|
return httpTraceRepository.findAll();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue