2019-06-13 17:11:42 +00:00
|
|
|
package request
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
|
2019-06-26 01:56:55 +00:00
|
|
|
"0cd.xyz-go/logger"
|
2019-06-13 17:11:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// File reads request json file
|
2019-06-26 01:56:55 +00:00
|
|
|
func File(path string) ([]byte, *logger.HTTPError) {
|
2019-06-13 17:11:42 +00:00
|
|
|
jsonFile, err := os.Open(path)
|
|
|
|
if err != nil {
|
2019-06-20 00:33:48 +00:00
|
|
|
log.Println("Error reading request. ", err)
|
2019-06-26 01:56:55 +00:00
|
|
|
return nil, &logger.HTTPError{Status: "500 Internal Server Error", StatusCode: 500}
|
2019-06-13 17:11:42 +00:00
|
|
|
}
|
|
|
|
defer jsonFile.Close()
|
|
|
|
byteValue, _ := ioutil.ReadAll(jsonFile)
|
2019-06-20 00:33:48 +00:00
|
|
|
return byteValue, nil
|
2019-06-13 17:11:42 +00:00
|
|
|
}
|