mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-11-01 19:32:27 +08:00
feature (plugin): API to develop plugin
This commit is contained in:
@ -2,8 +2,8 @@ package ctrl
|
||||
|
||||
import (
|
||||
. "github.com/mickael-kerjean/nuage/server/common"
|
||||
"github.com/mickael-kerjean/nuage/server/services"
|
||||
"github.com/mickael-kerjean/nuage/server/model"
|
||||
"github.com/mickael-kerjean/nuage/server/plugin"
|
||||
"io"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
@ -110,10 +110,17 @@ func FileCat(ctx App, res http.ResponseWriter, req *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
file, err = services.ProcessFileBeforeSend(file, &ctx, req, &res)
|
||||
if err != nil {
|
||||
SendErrorResult(res, err)
|
||||
return
|
||||
mType := GetMimeType(req.URL.Query().Get("path"))
|
||||
res.Header().Set("Content-Type", mType)
|
||||
|
||||
for _, obj := range plugin.ProcessFileContentBeforeSend() {
|
||||
if obj == nil {
|
||||
continue
|
||||
}
|
||||
if file, err = obj(file, &ctx, &res, req); err != nil {
|
||||
SendErrorResult(res, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
io.Copy(res, file)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user