diff --git a/ober.go b/ober.go index c05eb86..c4f4b7e 100644 --- a/ober.go +++ b/ober.go @@ -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) {