Skip to content

Commit 7704f03

Browse files
committed
implement get_cached_reference
1 parent 305f33c commit 7704f03

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

webserver.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,17 @@ func startWebserver(env Env, api *API) {
9191

9292
ctx.Response.AppendBodyString("true")
9393
case "/get_cached_reference":
94-
ctx.Request.Body()
94+
refNr := string(ctx.Request.Body())
95+
if refNr == "" {
96+
errorResp(ctx, 400, "reference number cannot be an empty string")
97+
return
98+
}
99+
100+
if api.CacheEntryExists(refNr) {
101+
ctx.Response.AppendBodyString("true")
102+
} else {
103+
ctx.Response.AppendBodyString("false")
104+
}
95105
default:
96106
errorResp(ctx, 404, "404 not found")
97107
return

0 commit comments

Comments
 (0)