forked from halo-dev/halo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/main/java/run/halo/app/controller/admin/api/TraceController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/run/halo/app/service/impl/TraceServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |