Use JSON for errors and page response
This commit is contained in:
14
response.go
Normal file
14
response.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Response struct {
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
func sendResponse(w http.ResponseWriter, msg string, args ...any) {
|
||||
sendJSON(w, Response{Message: fmt.Sprintf(msg, args...)})
|
||||
}
|
||||
Reference in New Issue
Block a user