17 lines
331 B
Go
17 lines
331 B
Go
package server
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
func (rest *REST) respMap(w http.ResponseWriter, key string, value interface{}) {
|
|
rest.resp(w, map[string]interface{}{key: value})
|
|
}
|
|
|
|
func (rest *REST) resp(w http.ResponseWriter, body interface{}) {
|
|
enc := json.NewEncoder(w)
|
|
enc.SetIndent("", " ")
|
|
enc.Encode(body)
|
|
}
|