Skip to content

Commit

Permalink
fix routing
Browse files Browse the repository at this point in the history
  • Loading branch information
posener committed Mar 5, 2018
1 parent 067afb5 commit 72317d9
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion client/app/components/file-tree/file-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const File = ({path, is_dir, instances, key, showFullPath = false}) => {
content = <span>
<Icon type={'file'}/> <Link to={viewURL}>{filename}</Link>
{instances.map(instance => <Tag key={instance.fs}><Link to={`${viewURL}?fs=${instance.fs}`}>{instance.fs} <span className="size">({filesize(instance.size, {fixed: 0}).human()})</span></Link></Tag>)}
<a href={`${window.location.origin}/${window.__INIT__.basePath}_dl/${path.join('/')}`} target="_blank" title="Download logs"><Icon type="download"/></a>
<a href={`${window.location.origin}${window.__INIT__.basePath}/_dl/${path.join('/')}`} target="_blank" title="Download logs"><Icon type="download"/></a>
</span>
}
return (
Expand Down
2 changes: 1 addition & 1 deletion client/app/components/file-view/file-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class FileView extends Component {
})
}}>Thread Name</Checkbox>

<a href={`${window.location.origin}/${window.__INIT__.basePath}_dl/${path.join('/')}?fs=${this.state.activeFs}`} target="_blank"><Icon type="eye"/> Show Original</a>
<a href={`${window.location.origin}${window.__INIT__.basePath}/_dl/${path.join('/')}?fs=${this.state.activeFs}`} target="_blank"><Icon type="eye"/> Show Original</a>


</div>
Expand Down
1 change: 0 additions & 1 deletion download/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type handler struct {
}

func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {

// collect all wanted sources
sources := querySources(r.URL.Query())
var downloadSources []source.Source
Expand Down
2 changes: 1 addition & 1 deletion dynamic/dynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {

// add websocket handler on the server root
route.Engine(rtr, "/", engine.New(h.engineCfg, src, h.parse, h.cache))
route.Download(rtr, "/", download.New(h.Root, src, h.cache))
route.Download(rtr, "/", download.New(filepath.Join(serverPath, "_dl"), src, h.cache))

if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"net/http"
"os"

"path/filepath"

"github.com/Sirupsen/logrus"
"github.com/Stratoscale/logserver/cache"
"github.com/Stratoscale/logserver/debug"
Expand Down Expand Up @@ -103,7 +105,7 @@ func main() {
failOnErr(err, "Creating config")
defer s.CloseSources()

dl := download.New(cfg.Route.RootPath, s, cache)
dl := download.New(filepath.Join(cfg.Route.RootPath, "_dl"), s, cache)
eng := engine.New(cfg.Global, s, parser, cache)

// put websocket handler behind the root and behind the proxy path
Expand Down
2 changes: 1 addition & 1 deletion route/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func Engine(r *mux.Router, basePath string, engine http.Handler) {
func Download(r *mux.Router, basePath string, h http.Handler) {
path := filepath.Join(basePath, pathDownload)
log.Debugf("Adding download route on %s", path)
r.PathPrefix(path).Handler(http.StripPrefix(path, h))
r.PathPrefix(path + "/").Handler(http.StripPrefix(path, h))
}

// Redirect mounts a redirect handler for a proxy on the router
Expand Down

0 comments on commit 72317d9

Please sign in to comment.