/
models.go
36 lines (30 loc) · 881 Bytes
/
models.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package patchitup
import (
"io/ioutil"
"regexp"
)
type serverRequest struct {
Signature string `json:"signature" binding:"required"`
PublicKey string `json:"public_key" binding:"required"`
Filename string `json:"filename"`
Patch patchFile `json:"patch"`
}
type patchFile struct {
Filename string
Patch string
Hash string
EpochTime int
}
type serverResponse struct {
Message string `json:"message"`
Success bool `json:"success"`
Patch patchFile `json:"patch,omitempty"`
Patches []patchFile `json:"patches,omitempty"`
}
var convertWindowsLineFeed = regexp.MustCompile(`\r?\n`)
func getFileText(pathToFile string) (fileText string, err error) {
bFile, err := ioutil.ReadFile(pathToFile)
bFile = convertWindowsLineFeed.ReplaceAll(bFile, []byte("\n"))
fileText = string(bFile)
return
}