mirror of
https://github.com/valmojr/armatak.git
synced 2026-06-13 15:03:30 +00:00
added postMarker command to extensions
This commit is contained in:
@@ -40,7 +40,7 @@ func armatak_controller_post_marker(
|
||||
ctx a3interface.ArmaExtensionContext,
|
||||
data string,
|
||||
) (string, error) {
|
||||
return invalidCallExtensionMethod("post market requires args")
|
||||
return invalidCallExtensionMethod("post marker requires args")
|
||||
}
|
||||
|
||||
func armatak_controller_args_post_marker(
|
||||
@@ -50,5 +50,5 @@ func armatak_controller_args_post_marker(
|
||||
) (string, error) {
|
||||
sanitazeArgs(args)
|
||||
|
||||
return "", nil
|
||||
return armatak_service_post_marker(args)
|
||||
}
|
||||
|
||||
@@ -31,4 +31,11 @@ func init() {
|
||||
SetFunction(armatak_controller_get_auth_token).
|
||||
SetArgsFunction(armatak_controller_args_get_auth_token).
|
||||
Register()
|
||||
|
||||
a3interface.NewRegistration("post_marker").
|
||||
SetDefaultResponse("getting uuid4").
|
||||
SetRunInBackground(true).
|
||||
SetFunction(armatak_controller_post_marker).
|
||||
SetArgsFunction(armatak_controller_args_post_marker).
|
||||
Register()
|
||||
}
|
||||
|
||||
@@ -43,3 +43,19 @@ func armatak_service_get_auth_token(args []string) (string, error) {
|
||||
|
||||
return authToken, nil
|
||||
}
|
||||
|
||||
func armatak_service_post_marker(args []string) (string, error) {
|
||||
marker, markerError := parseMarkerArgs(args)
|
||||
|
||||
if markerError != nil {
|
||||
return "", markerError
|
||||
}
|
||||
|
||||
response, responseError := postRequest(args[7]+"/api/markers?auth_token="+args[8], marker)
|
||||
|
||||
if responseError != nil {
|
||||
return "", responseError
|
||||
}
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ func postRequestWithoutToken(route string, body any) ([]byte, error) {
|
||||
return (parsedBody), nil
|
||||
}
|
||||
|
||||
func postRequest(route string, body any, token string) (string, error) {
|
||||
func postRequest(route string, body any) (string, error) {
|
||||
jsonData, err := json.Marshal(body)
|
||||
if err != nil {
|
||||
fmt.Println("Error marshalling payload:", err)
|
||||
@@ -116,8 +116,6 @@ func postRequest(route string, body any, token string) (string, error) {
|
||||
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
fmt.Println("Error sending request:", err)
|
||||
|
||||
Reference in New Issue
Block a user