From f0555e8d6ab5ab2a24027576d30a796220f017a2 Mon Sep 17 00:00:00 2001 From: daru Date: Sat, 14 May 2022 14:10:04 +0200 Subject: [PATCH] New log endpoint --- ober.go | 12 ++++++++++++ ring.go | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ober.go b/ober.go index e97d281..60f828d 100644 --- a/ober.go +++ b/ober.go @@ -20,6 +20,7 @@ func RunWebserv() { r.GET("/api/anime/{id}", Headers(AnimeGet)) r.GET("/api/animesearch", Headers(AnimeSearchGet)) r.GET("/api/appointment", Headers(AppointmentGet)) + r.GET("/api/log", Headers(LogGet)) r.GET("/api/user/{user?}", Headers(UserGet)) r.GET("/api/watch/{user?}", Headers(WatchGet)) r.GET("/api/watchext/{user?}", Headers(WatchExtendedGet)) @@ -140,6 +141,17 @@ func AppointmentGet(ctx *fasthttp.RequestCtx) { ctx.SetStatusCode(fasthttp.StatusNotImplemented) } +func LogGet(ctx *fasthttp.RequestCtx) { + _, err := ctx.WriteString(logOut.String()) + if err != nil { + addErrorToCtx(ctx, err) + ctx.SetStatusCode(fasthttp.StatusInternalServerError) + return + } + ctx.SetContentType("text/plain; charset=utf-8") + ctx.SetStatusCode(fasthttp.StatusOK) +} + func UserGet(ctx *fasthttp.RequestCtx) { usrVal := ctx.UserValue("user") users := make([]User, 0) diff --git a/ring.go b/ring.go index d3e6575..46e5e48 100644 --- a/ring.go +++ b/ring.go @@ -83,7 +83,7 @@ func (rb *RingBuf) Bytes() []byte { } return out } - out := make([]byte, rb.writePos+1) + out := make([]byte, rb.writePos) copy(out, rb.data[:rb.writePos]) return out }