Beispiel #1
0
func (rbac *myRbac) Post(w http.ResponseWriter, r *http.Request) (status int, data interface{}) {
	body, err := ioutil.ReadAll(r.Body)
	if err != nil {
		return http.StatusInternalServerError, err.Error()
	}
	defer r.Body.Close()
	var m gorbac.Map
	if err := json.Unmarshal(body, &m); err != nil {
		return http.StatusInternalServerError, err.Error()
	}
	rbac.Rbac = gorbac.Restore(m)
	return http.StatusOK, rbac.Rbac.Dump()
}
Beispiel #2
0
func postHandler(ctx *possum.Context) error {
	body, err := ioutil.ReadAll(ctx.Request.Body)
	if err != nil {
		return err
	}
	defer ctx.Request.Body.Close()
	var m gorbac.Map
	if err := json.Unmarshal(body, &m); err != nil {
		return err
	}
	rbac = gorbac.Restore(m)
	ctx.Response.Data = rbac.Dump()
	return nil
}