mirror of
https://github.com/komari-monitor/komari.git
synced 2026-11-20 14:51:16 +00:00
22 lines
474 B
Go
22 lines
474 B
Go
package admin
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/komari-monitor/komari/internal/plugin"
|
|
)
|
|
|
|
// ServePluginFile serves a static file from an installed plugin directory,
|
|
// used by injected plugin admin pages.
|
|
func ServePluginFile(c *gin.Context) {
|
|
name := strings.TrimPrefix(c.Param("filepath"), "/")
|
|
full, err := plugin.ResolveFile(c.Param("short"), name)
|
|
if err != nil {
|
|
c.Status(http.StatusNotFound)
|
|
return
|
|
}
|
|
c.File(full)
|
|
}
|