mirror of
https://github.com/Warky-Devs/ResolveSpec.git
synced 2025-05-19 05:07:30 +00:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f3ca6c356a | ||
|
5f1526b0f4 | ||
|
08e77d5d30 |
26
make_release.sh
Normal file
26
make_release.sh
Normal file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Ask if the user wants to make a release version
|
||||
read -p "Do you want to make a release version? (y/n): " make_release
|
||||
|
||||
if [[ $make_release =~ ^[Yy]$ ]]; then
|
||||
# Ask the user for the version number
|
||||
read -p "Enter the version number : " version
|
||||
|
||||
# Prepend 'v' to the version if it doesn't start with it
|
||||
if ! [[ $version =~ ^v ]]; then
|
||||
version="v$version"
|
||||
else
|
||||
echo "Version already starts with 'v'."
|
||||
fi
|
||||
|
||||
# Create an annotated tag
|
||||
git tag -a "$version" -m "Released Core $version"
|
||||
|
||||
# Push the tag to the remote repository
|
||||
git push origin "$version"
|
||||
|
||||
echo "Tag $version created for Core and pushed to the remote repository."
|
||||
else
|
||||
echo "No release version created."
|
||||
fi
|
@ -3,6 +3,7 @@ package resolvespec
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/Warky-Devs/ResolveSpec/pkg/logger"
|
||||
@ -25,11 +26,25 @@ func NewAPIHandler(db *gorm.DB) *APIHandler {
|
||||
// Main handler method
|
||||
func (h *APIHandler) Handle(w http.ResponseWriter, r *http.Request, params map[string]string) {
|
||||
var req RequestBody
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
|
||||
if r.Body == nil {
|
||||
logger.Error("No body to decode")
|
||||
h.sendError(w, http.StatusBadRequest, "invalid_request", "No body to decode", nil)
|
||||
return
|
||||
} else {
|
||||
defer r.Body.Close()
|
||||
}
|
||||
if bodyContents, err := io.ReadAll(r.Body); err != nil {
|
||||
logger.Error("Failed to decode read body: %v", err)
|
||||
h.sendError(w, http.StatusBadRequest, "read_request", "Invalid request body", err)
|
||||
return
|
||||
} else {
|
||||
if err := json.Unmarshal(bodyContents, &req); err != nil {
|
||||
logger.Error("Failed to decode request body: %v", err)
|
||||
h.sendError(w, http.StatusBadRequest, "invalid_request", "Invalid request body", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
schema := params["schema"]
|
||||
entity := params["entity"]
|
||||
|
@ -68,8 +68,8 @@ func (h *APIHandler) getModelForEntity(schema, name string) (interface{}, error)
|
||||
|
||||
func (h *APIHandler) RegisterModel(schema, name string, model interface{}) error {
|
||||
fullname := fmt.Sprintf("%s.%s", schema, name)
|
||||
model, err := models.GetModelByName(fullname)
|
||||
if model != nil && err != nil {
|
||||
oldModel, err := models.GetModelByName(fullname)
|
||||
if oldModel != nil && err != nil {
|
||||
return fmt.Errorf("model %s already exists", fullname)
|
||||
}
|
||||
err = models.RegisterModel(model, fullname)
|
||||
|
Loading…
Reference in New Issue
Block a user