workign on the yamls
This commit is contained in:
28
main.go
28
main.go
@@ -10,6 +10,7 @@ import (
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -297,7 +298,7 @@ func upload() http.Handler {
|
||||
|
||||
func createPackageAndRename() http.Handler{
|
||||
return http.HandlerFunc(func(res http.ResponseWriter, req *http.Request){
|
||||
|
||||
slog.Debug(req.Host)
|
||||
})
|
||||
}
|
||||
// index creates an HTTP handler that serves the main page with data from the database.
|
||||
@@ -342,7 +343,31 @@ func index(sqldb *sql.DB, lang string) http.Handler {
|
||||
})
|
||||
|
||||
}
|
||||
func renameForFile() http.Handler{
|
||||
return http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
||||
init:=req.FormValue("Vendor")
|
||||
init=string(init[0])
|
||||
regexext:= regexp.MustCompile(`\.[\u\l]{1,5}$`)
|
||||
extention:=regexext.FindString(req.FormValue("InstallerUrl"))
|
||||
yamlmodel:=yaml{
|
||||
PUB: req.FormValue("Vendor"),
|
||||
HASH: req.FormValue("InstallerSha256"),
|
||||
URL: req.FormValue("InstallerUrl"),
|
||||
NAME: req.FormValue("Package"),
|
||||
PID: req.FormValue("Vendor")+"."+req.FormValue("Package"),
|
||||
VER: req.FormValue("PackageVersion"),
|
||||
INIT: init,
|
||||
LOCATION: os.Getenv("packagesDirectory")+"/"+init+"/"+req.FormValue("Vendor")+"/"+req.FormValue("Package")+"/"+req.FormValue("PackageVersion"),
|
||||
FILELOCATION: os.Getenv("installationDirectory")+"/"+req.FormValue("Vendor")+"."+req.FormValue("Package")+".v."+req.FormValue("PackageVersion")+extention ,
|
||||
}
|
||||
|
||||
CreateDirectoryInPackageDir(yamlmodel)
|
||||
CreateYaml(yamlmodel)
|
||||
// fur:=
|
||||
|
||||
// slog.Debug(fur)
|
||||
})
|
||||
}
|
||||
// public serves static files from the "public" directory.
|
||||
// Returns: An http.Handler that serves static files.
|
||||
func public() http.Handler {
|
||||
@@ -384,6 +409,7 @@ func main() {
|
||||
mux.Handle("/up", uploadFileForServer(db,"eng"))
|
||||
mux.Handle("/upload",upload())
|
||||
mux.Handle("/pkg",getJson(db))
|
||||
mux.Handle("/ren",renameForFile())
|
||||
addr := fmt.Sprintf(":%s", "12312")
|
||||
server := http.Server{
|
||||
Addr: addr,
|
||||
|
Reference in New Issue
Block a user