GET appointments

This commit is contained in:
daru
2022-05-28 12:30:21 +02:00
parent b2b6c97282
commit a079fbf9db

25
ober.go
View File

@@ -153,7 +153,30 @@ func AnimeSearchGet(ctx *fasthttp.RequestCtx) {
}
func AppointmentGet(ctx *fasthttp.RequestCtx) {
ctx.SetStatusCode(fasthttp.StatusNotImplemented)
appoints, err := ReadAppointments()
// check if no appointments exists
if err != nil {
if strings.Contains(err.Error(), "not found") || err == nutsdb.ErrBucketEmpty {
appoints = make([]Appointment, 0)
} else {
addErrorToCtx(ctx, err)
return
}
}
bytes, err := json.Marshal(appoints)
if err != nil {
addErrorToCtx(ctx, err)
return
}
_, err = ctx.Write(bytes)
if err != nil {
addErrorToCtx(ctx, err)
return
}
ctx.SetContentType("application/json; charset=utf-8")
ctx.SetStatusCode(fasthttp.StatusOK)
}
func ChatGet(ctx *fasthttp.RequestCtx) {