mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-10-30 01:26:43 +08:00
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package common
|
|
|
|
import (
|
|
"io"
|
|
"net/http"
|
|
"github.com/gorilla/mux"
|
|
)
|
|
|
|
const (
|
|
PluginTypeBackend = "backend"
|
|
PluginTypeMiddleware = "middleware"
|
|
)
|
|
|
|
type Plugin struct {
|
|
Type string
|
|
Enable bool
|
|
}
|
|
|
|
|
|
type Register struct{}
|
|
type Get struct{}
|
|
|
|
var Hooks = struct {
|
|
Get Get
|
|
Register Register
|
|
}{
|
|
Get: Get{},
|
|
Register: Register{},
|
|
}
|
|
|
|
var process_file_content_before_send []func(io.Reader, *App, *http.ResponseWriter, *http.Request) (io.Reader, error)
|
|
func (this Register) ProcessFileContentBeforeSend(fn func(io.Reader, *App, *http.ResponseWriter, *http.Request) (io.Reader, error)) {
|
|
process_file_content_before_send = append(process_file_content_before_send, fn)
|
|
}
|
|
func (this Get) ProcessFileContentBeforeSend() []func(io.Reader, *App, *http.ResponseWriter, *http.Request) (io.Reader, error) {
|
|
return process_file_content_before_send
|
|
}
|
|
|
|
var http_endpoint []func(*mux.Router) error
|
|
func (this Register) HttpEndpoint(fn func(*mux.Router) error) {
|
|
http_endpoint = append(http_endpoint, fn)
|
|
}
|
|
func (this Get) HttpEndpoint() []func(*mux.Router) error {
|
|
return http_endpoint
|
|
}
|