69 lines
1.3 KiB
Go
Raw Normal View History

2020-11-21 23:42:34 +01:00
package members
2020-11-21 23:39:24 +01:00
import (
"net/http"
"demodesk/neko/internal/utils"
)
2020-11-22 00:06:55 +01:00
type MemberCreatePayload struct {
ID string `json:"id"`
}
type MemberDataPayload struct {
ID string `json:"id"`
Name string `json:"name"`
Admin bool `json:"admin"`
}
2020-11-21 23:42:34 +01:00
func (h *MembersHandler) membersCreate(w http.ResponseWriter, r *http.Request) {
2020-11-22 00:06:55 +01:00
data := &MemberDataPayload{}
if !utils.HttpJsonRequest(w, r, data) {
return
}
2020-11-21 23:39:24 +01:00
2020-11-22 00:06:55 +01:00
utils.HttpSuccess(w, MemberCreatePayload{
ID: "some_id",
})
2020-11-21 23:39:24 +01:00
}
2020-11-21 23:42:34 +01:00
func (h *MembersHandler) membersRead(w http.ResponseWriter, r *http.Request) {
2020-11-22 00:06:55 +01:00
data := &MemberDataPayload{}
if !utils.HttpJsonRequest(w, r, data) {
return
}
2020-11-21 23:39:24 +01:00
member := GetMember(r)
2020-11-22 00:06:55 +01:00
utils.HttpSuccess(w, MemberDataPayload{
ID: member.ID(),
Name: member.Name(),
Admin: member.Admin(),
})
2020-11-21 23:39:24 +01:00
}
2020-11-21 23:42:34 +01:00
func (h *MembersHandler) membersUpdate(w http.ResponseWriter, r *http.Request) {
2020-11-22 00:06:55 +01:00
data := &MemberDataPayload{}
if !utils.HttpJsonRequest(w, r, data) {
return
}
2020-11-21 23:39:24 +01:00
member := GetMember(r)
2020-11-22 00:06:55 +01:00
utils.HttpSuccess(w, MemberDataPayload{
ID: member.ID(),
Name: member.Name(),
Admin: member.Admin(),
})
2020-11-21 23:39:24 +01:00
}
2020-11-21 23:42:34 +01:00
func (h *MembersHandler) membersDelete(w http.ResponseWriter, r *http.Request) {
2020-11-21 23:39:24 +01:00
member := GetMember(r)
2020-11-22 00:06:55 +01:00
utils.HttpSuccess(w, MemberDataPayload{
ID: member.ID(),
Name: member.Name(),
Admin: member.Admin(),
})
2020-11-21 23:39:24 +01:00
}