Skip to content

Commit

Permalink
deploy and improved windows installed (prevents duplicates on path)
Browse files Browse the repository at this point in the history
  • Loading branch information
quiquelhappy committed Oct 21, 2021
1 parent 14468b7 commit 4840ea9
Show file tree
Hide file tree
Showing 12 changed files with 418 additions and 40 deletions.
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

3 changes: 2 additions & 1 deletion .idea/grif-cli.iml → .idea/cli.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions .idea/remote-targets.xml

This file was deleted.

22 changes: 22 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 99 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 83 additions & 0 deletions src/api/API.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"io/ioutil"
"net/http"
"os"
)

func Request(path string, data map[string]interface{}, hash interface{}) (response io.Reader,err error) {
Expand Down Expand Up @@ -70,4 +71,86 @@ func Request(path string, data map[string]interface{}, hash interface{}) (respon
return result,errors.New(errorInfo.Error.(string))
}
return result, err
}

func WorldWideWebRequest(url string, data map[string]interface{}) (response io.Reader,err error) {
var result io.Reader = nil
var body []byte
err = nil
client := &http.Client{}
if data != nil && len(data) > 0 {
postString, err := json.Marshal(&data)
if err!=nil {
return nil, err
}
req, err := http.NewRequest("POST",url, bytes.NewBuffer(postString))
if err!=nil {
return nil, err
}
req.Header.Set("Accept","application/json")
req.Header.Set("User-Agent","grifpkg/cli")
res, err := client.Do(req)
if err!=nil {
return nil, err
}
defer func(Body io.ReadCloser) {
err = Body.Close()
}(res.Body)
body, err = ioutil.ReadAll(res.Body)
if err!=nil {
return nil, err
}
result = bytes.NewReader(body)
} else {
req, err := http.NewRequest("GET",url, nil)
if err!=nil {
return nil, err
}
req.Header.Set("Accept","application/json")
req.Header.Set("User-Agent","grifpkg/cli")
res, err := client.Do(req)
defer func(Body io.ReadCloser) {
err = Body.Close()
}(res.Body)
body, err = ioutil.ReadAll(res.Body)
if err!=nil {
return nil, err
}
result = bytes.NewReader(body)
}
return result, err
}

func DownloadFile(URL string, outputDirectoryPath interface{}, outputName string) (outputPath string,err error){

var outputPathString string = ""
if outputDirectoryPath!=nil {
outputPathString=outputDirectoryPath.(string)
} else {
outputPathString, err = os.Getwd()
if err != nil {
return "", err
}
}
outputPath=outputPathString+string(os.PathSeparator)+outputName
resp, err := http.Get(URL)
if err != nil {
return "", err
}
defer resp.Body.Close()

err = os.Mkdir(outputPathString, 0700)
if err != nil && !os.IsExist(err) {
return "", err
}
out, err := os.Create(outputPath)
if err != nil && !os.IsExist(err) {
return "", err
}
defer out.Close()
_, err = io.Copy(out, resp.Body)
if err != nil {
return "", err
}
return outputPath, nil
}
2 changes: 1 addition & 1 deletion src/api/Globals.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package api

const Version = "1.1.0"
const Version = "1.1.1"
const KeychainService = "grifpkg"
const KeychainHash = "session"
Loading

0 comments on commit 4840ea9

Please sign in to comment.