🐛 Fix the POST script request

This commit is contained in:
M. Mert Yildiran 2023-11-03 01:09:22 +03:00
parent 7737bdf4fc
commit 7ce18ecaa9
No known key found for this signature in database
GPG Key ID: DA5D6DCBB758A461

View File

@ -121,11 +121,21 @@ func (connector *Connector) PostLicense(license string) {
}
}
type postScriptRequest struct {
Title string `json:"title"`
Code string `json:"code"`
}
func (connector *Connector) PostScript(script *misc.Script) (index int64, err error) {
postScriptUrl := fmt.Sprintf("%s/scripts", connector.url)
payload := postScriptRequest{
Title: script.Title,
Code: script.Code,
}
var scriptMarshalled []byte
if scriptMarshalled, err = json.Marshal(script); err != nil {
if scriptMarshalled, err = json.Marshal(payload); err != nil {
log.Error().Err(err).Msg("Failed to marshal the script:")
} else {
ok := false