gPanel/pkg/api/settings/bundle_name.go
2017-12-08 15:11:18 -06:00

23 lines
622 B
Go

package settings
import (
"net/http"
"strconv"
"strings"
"log"
)
func BundleName(res http.ResponseWriter, req *http.Request, logger *log.Logger, dir string) bool {
if req.Method != "GET" {
logger.Println(req.URL.Path + "::" + req.Method + "::" + strconv.Itoa(http.StatusNotFound) + "::" + http.StatusText(http.StatusMethodNotAllowed))
http.Error(res, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)
return false
}
dir = strings.Replace(dir, "bundles/bundle_", "", 1)
dir = strings.Replace(dir, "/", "", 1)
res.WriteHeader(http.StatusOK)
res.Write([]byte(dir))
return true
}