Added backend

This commit is contained in:
2022-02-06 22:51:36 +01:00
parent 77599e26f8
commit 431cadaeea
35 changed files with 2422 additions and 0 deletions

23
backend/server/assets.go Normal file
View File

@@ -0,0 +1,23 @@
package server
import (
"TheAdversary/database"
"github.com/gorilla/mux"
"mime"
"net/http"
"path"
)
func Assets(w http.ResponseWriter, r *http.Request) {
assetName := mux.Vars(r)["asset"]
var buf []interface{}
database.GetDB().Table("assets").Select("data").Find(&buf, "link = ?", assetName)
if buf == nil {
Error404(w, r)
} else {
data := buf[0].([]byte)
w.Header().Set("Content-Type", mime.TypeByExtension(path.Ext(assetName)))
w.Write(data)
}
}