Skip to content

Commit

Permalink
Allow viewing of logfiles inside archives in nested folders
Browse files Browse the repository at this point in the history
  • Loading branch information
lukashinsch committed Mar 7, 2015
1 parent 15718b7 commit 6e5d524
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
package eu.hinsch.spring.boot.actuator.logview;

import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.endpoint.Endpoint;
import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.ui.Model;
import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
Expand Down Expand Up @@ -116,8 +117,8 @@ private List<FileEntry> sortFiles(List<FileEntry> files, SortBy sortBy, boolean
return sortedFiles;
}

@RequestMapping("/view/{filename}/")
public void view(@PathVariable String filename, @RequestParam(required = false) String base, HttpServletResponse response) throws IOException {
@RequestMapping("/view")
public void view(@RequestParam String filename, @RequestParam(required = false) String base, HttpServletResponse response) throws IOException {
securityCheck(filename);
Path path = loggingPath(base);
getFileProvider(path).streamContent(path, filename, response.getOutputStream());
Expand Down
2 changes: 1 addition & 1 deletion lib/src/main/resources/templates/logview.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</#if>
&nbsp;
<#if file.fileType == 'FILE'>
<a href="view/${file.filename}/?base=${base}">${file.filename}</a>
<a href="view?filename=${file.filename}&base=${base}">${file.filename}</a>
</#if>
<#if file.fileType == 'ARCHIVE'>
<a href="?base=${base}/${file.filename}">${file.filename}</a>
Expand Down

0 comments on commit 6e5d524

Please sign in to comment.