2 Commits

Author SHA256 Message Date
Michal Suchanek
f878e4895e Make it possible to specify BR format in query string
instead of

curl -H 'accept: application/obs+xml' https://br.opensuse.org/status/Java:packages/jameica
curl -H 'accept: application/json' https://br.opensuse.org/status/Java:packages/jameica

this can be used

curl https://br.opensuse.org/status/Java:packages/jameica?format=xml
curl https://br.opensuse.org/status/Java:packages/jameica?format=json

which provides much simpler and easier to understand interface.

Fixes: #94
2025-11-06 16:56:09 +01:00
20e1109602 spec: packaging fixes
* Update Version to 1, since we now have devel project and updates
should have version bump instead of downgrade
* other fixes
2025-11-05 16:38:15 +01:00
3 changed files with 31 additions and 8 deletions

View File

@@ -17,7 +17,7 @@
Name: autogits
Version: 0
Version: 1
Release: 0
Summary: GitWorkflow utilities
License: GPL-2.0-or-later
@@ -41,6 +41,7 @@ Command-line tool to import devel projects from obs to git
%package doc
Summary: Common documentation files
BuildArch: noarch
%description -n autogits-doc
Common documentation files
@@ -56,10 +57,11 @@ with a topic
%package gitea-status-proxy
Summary: gitea-status-proxy
Summary: Proxy for setting commit status in Gitea
%description gitea-status-proxy
Setting commit status requires code write access token. This proxy
is middleware that delegates status setting without access to other APIs
%package group-review
Summary: Reviews of groups defined in ProjectGit
@@ -213,6 +215,18 @@ install -D -m0755 utils/hujson/hujson
%postun obs-status-service
%service_del_postun obs-status-service.service
%pre workflow-pr
%service_add_pre workflow-direct@.service
%post workflow-pr
%service_add_post workflow-direct@.service
%preun workflow-pr
%service_del_preun workflow-direct@.service
%postun workflow-pr
%service_del_postun workflow-direct@.service
%files devel-importer
%license COPYING
%doc devel-importer/README.md

View File

@@ -275,7 +275,7 @@ func main() {
res.Write([]byte("404 page not found\n"))
})
http.HandleFunc("GET /status/{Project}", func(res http.ResponseWriter, req *http.Request) {
mime := ParseMimeHeader(req)
mime := ParseMimeHeaderAndQuery(req)
obsPrj := req.PathValue("Project")
common.LogInfo(" GET /status/"+obsPrj, "["+mime.MimeType()+"]")
@@ -296,7 +296,7 @@ func main() {
}
})
http.HandleFunc("GET /status/{Project}/{Package}", func(res http.ResponseWriter, req *http.Request) {
mime := ParseMimeHeader(req)
mime := ParseMimeHeaderAndQuery(req)
obsPrj := req.PathValue("Project")
obsPkg := req.PathValue("Package")
common.LogInfo(" GET /status/"+obsPrj+"/"+obsPkg, "["+mime.MimeType()+"]")
@@ -326,7 +326,7 @@ func main() {
})
http.HandleFunc("GET /status/{Project}/{Package}/{Repository}", func(res http.ResponseWriter, req *http.Request) {
mime := ParseMimeHeader(req)
mime := ParseMimeHeaderAndQuery(req)
obsPrj := req.PathValue("Project")
obsPkg := req.PathValue("Package")
repo := req.PathValue("Repository")
@@ -355,7 +355,7 @@ func main() {
}
})
http.HandleFunc("GET /status/{Project}/{Package}/{Repository}/{Arch}", func(res http.ResponseWriter, req *http.Request) {
mime := ParseMimeHeader(req)
mime := ParseMimeHeaderAndQuery(req)
prj := req.PathValue("Project")
pkg := req.PathValue("Package")
repo := req.PathValue("Repository")

View File

@@ -21,7 +21,16 @@ var AcceptedStatusMimes []string = []string{
XmlMime,
}
func ParseMimeHeader(req *http.Request) *MimeHeader {
func ParseMimeHeaderAndQuery(req *http.Request) *MimeHeader {
format := req.URL.Query().Get("format")
switch format {
case "svg":
return &MimeHeader{MimeHeader: SvgMime}
case "json":
return &MimeHeader{MimeHeader: JsonMime}
case "xml":
return &MimeHeader{MimeHeader: XmlMime}
}
proposedMimes := req.Header.Values("Accept")
mime := MimeHeader{MimeHeader: SvgMime}
if len(proposedMimes) == 0 {