mirror of
https://tvoygit.ru/Djam/r11_urpm-repo.git
synced 2025-02-23 18:22:47 +00:00
update
This commit is contained in:
parent
b9d5f0b884
commit
140721e7fc
4 changed files with 40 additions and 5 deletions
|
@ -1,2 +1,6 @@
|
|||
# r11_urpm-repo
|
||||
|
||||
Проверим успешную загрузку пакета:
|
||||
|
||||
|
||||
curl -X POST "http://localhost:8888/x86_64" -H "Authorization: Bearer your_secret_token_here" -F "package=@/path/to/your/package.rpm"
|
||||
|
|
23
api.go
23
api.go
|
@ -3,9 +3,32 @@ package main
|
|||
import (
|
||||
"net/http"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"strings"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func (r *Repository) UploadHandler(w http.ResponseWriter, req *http.Request) {
|
||||
authHeader := req.Header.Get("Authorization")
|
||||
if authHeader == "" {
|
||||
http.Error(w, "Unauthorized", http.StatusUnauthorized)
|
||||
logger.Error("Authorization header missing")
|
||||
return
|
||||
}
|
||||
|
||||
parts := strings.Split(authHeader, " ")
|
||||
if len(parts) != 2 || parts[0] != "Bearer" {
|
||||
http.Error(w, "Unauthorized", http.StatusUnauthorized)
|
||||
logger.Error("Invalid Authorization header format")
|
||||
return
|
||||
}
|
||||
|
||||
token := parts[1]
|
||||
if token != viper.GetString("auth.token") {
|
||||
http.Error(w, "Unauthorized", http.StatusUnauthorized)
|
||||
logger.Error("Invalid token")
|
||||
return
|
||||
}
|
||||
|
||||
arch := chi.URLParam(req, "arch")
|
||||
if arch == "" {
|
||||
http.Error(w, "Invalid architecture", http.StatusBadRequest)
|
||||
|
|
|
@ -4,3 +4,6 @@ repository:
|
|||
path: "/var/www/html/urpm-repo"
|
||||
log:
|
||||
level: "info"
|
||||
auth:
|
||||
token: "your_secret_token_here"
|
||||
|
||||
|
|
11
nginx.conf
11
nginx.conf
|
@ -30,15 +30,21 @@ http {
|
|||
listen 8080;
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
root /var/www/html/urpm-repo;
|
||||
|
||||
location / {
|
||||
autoindex on;
|
||||
autoindex_exact_size off;
|
||||
autoindex_localtime on;
|
||||
}
|
||||
|
||||
location ~ ^/(x86_64|i386|aarch64|riscv64|noarch|src)/ {
|
||||
alias /var/www/html/urpm-repo/$1/;
|
||||
autoindex on;
|
||||
autoindex_exact_size off;
|
||||
autoindex_localtime on;
|
||||
}
|
||||
|
||||
location ~ ^/(x86_64|i386|aarch64|riscv64|noarch|src)/media_info/ {
|
||||
autoindex on;
|
||||
autoindex_exact_size off;
|
||||
autoindex_localtime on;
|
||||
|
@ -50,4 +56,3 @@ http {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue