mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
CRUD add payloads.
This commit is contained in:
parent
43781cdf52
commit
d49542013b
@ -6,25 +6,63 @@ import (
|
|||||||
"demodesk/neko/internal/utils"
|
"demodesk/neko/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (h *MembersHandler) membersCreate(w http.ResponseWriter, r *http.Request) {
|
type MemberCreatePayload struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
utils.HttpSuccess(w)
|
type MemberDataPayload struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Admin bool `json:"admin"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *MembersHandler) membersCreate(w http.ResponseWriter, r *http.Request) {
|
||||||
|
data := &MemberDataPayload{}
|
||||||
|
if !utils.HttpJsonRequest(w, r, data) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
utils.HttpSuccess(w, MemberCreatePayload{
|
||||||
|
ID: "some_id",
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *MembersHandler) membersRead(w http.ResponseWriter, r *http.Request) {
|
func (h *MembersHandler) membersRead(w http.ResponseWriter, r *http.Request) {
|
||||||
|
data := &MemberDataPayload{}
|
||||||
|
if !utils.HttpJsonRequest(w, r, data) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
member := GetMember(r)
|
member := GetMember(r)
|
||||||
|
|
||||||
utils.HttpSuccess(w, "Your name is " + member.Name() + ".")
|
utils.HttpSuccess(w, MemberDataPayload{
|
||||||
|
ID: member.ID(),
|
||||||
|
Name: member.Name(),
|
||||||
|
Admin: member.Admin(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *MembersHandler) membersUpdate(w http.ResponseWriter, r *http.Request) {
|
func (h *MembersHandler) membersUpdate(w http.ResponseWriter, r *http.Request) {
|
||||||
|
data := &MemberDataPayload{}
|
||||||
|
if !utils.HttpJsonRequest(w, r, data) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
member := GetMember(r)
|
member := GetMember(r)
|
||||||
|
|
||||||
utils.HttpSuccess(w, "Your name is " + member.Name() + ".")
|
utils.HttpSuccess(w, MemberDataPayload{
|
||||||
|
ID: member.ID(),
|
||||||
|
Name: member.Name(),
|
||||||
|
Admin: member.Admin(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *MembersHandler) membersDelete(w http.ResponseWriter, r *http.Request) {
|
func (h *MembersHandler) membersDelete(w http.ResponseWriter, r *http.Request) {
|
||||||
member := GetMember(r)
|
member := GetMember(r)
|
||||||
|
|
||||||
utils.HttpSuccess(w, "Your name is " + member.Name() + ".")
|
utils.HttpSuccess(w, MemberDataPayload{
|
||||||
|
ID: member.ID(),
|
||||||
|
Name: member.Name(),
|
||||||
|
Admin: member.Admin(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user