Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sundowndev
GitHub Repository: sundowndev/phoneinfoga
Path: blob/master/web/response.go
988 views
1
package web
2
3
import (
4
"strings"
5
)
6
7
func successResponse(msg ...string) JSONResponse {
8
var message string = ""
9
10
if len(msg) > 0 {
11
message = strings.Join(msg, " ")
12
}
13
14
return JSONResponse{
15
Success: true,
16
Message: message,
17
}
18
}
19
20
func errorResponse(msg ...string) JSONResponse {
21
var message string = "An error occurred"
22
23
if len(msg) > 0 {
24
message = strings.Join(msg, " ")
25
}
26
27
return JSONResponse{
28
Success: false,
29
Error: message,
30
}
31
}
32
33