v0.1.1, Added SetJSON for content
This commit is contained in:
parent
3cc040b587
commit
e1d894678c
11
srvrsp.go
11
srvrsp.go
|
@ -1,6 +1,7 @@
|
|||
package httpsrv
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
|
@ -92,6 +93,16 @@ func (r *Rec) Sent() {
|
|||
r._sent = true
|
||||
}
|
||||
|
||||
//Установить ответ в JSON
|
||||
func (r *Rec) SetJSON(data interface{}) *Rec {
|
||||
dta, e := json.Marshal(data)
|
||||
if e != nil {
|
||||
errs.RaiseError(ErrJSONError, e.Error())
|
||||
dta = []byte("Error: " + e.Error())
|
||||
}
|
||||
return r.SetContent(dta)
|
||||
}
|
||||
|
||||
//Установить тело ответа
|
||||
func (r *Rec) SetContent(content []byte) *Rec {
|
||||
r._content = content
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
package httpsrv
|
||||
|
||||
const Version = "0.1.0"
|
||||
const Version = "0.1.1"
|
||||
|
|
Loading…
Reference in New Issue