From 66df8b0e86f76fa3154ac9fad880d022c6c7843e Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sun, 5 Jan 2025 16:55:49 -0800 Subject: [PATCH] fix whois gitignore --- .gitignore | 3 ++- api/whois/whois.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 api/whois/whois.go diff --git a/.gitignore b/.gitignore index 89d8123..db9f298 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.env -whois +*whois +!*whois/ *.db diff --git a/api/whois/whois.go b/api/whois/whois.go new file mode 100644 index 0000000..a30661d --- /dev/null +++ b/api/whois/whois.go @@ -0,0 +1,28 @@ +package whois + +import ( + "log" + "net/http" + + "git.simponic.xyz/simponic/whois/api/types" + "git.simponic.xyz/simponic/whois/database" +) + +func FetchLatestName(context *types.RequestContext, req *http.Request, resp http.ResponseWriter) types.ContinuationChain { + return func(success types.Continuation, failure types.Continuation) types.ContinuationChain { + updates, err := database.ListUpdates(context.DBConn, database.ListUpdatesQuery{Limit: 1}) + if err != nil { + log.Printf("err fetching updates %s", err) + resp.WriteHeader(http.StatusInternalServerError) + return failure(context, req, resp) + } + if len(updates) == 0 { + log.Printf("no updates yet") + resp.WriteHeader(http.StatusNotFound) + return failure(context, req, resp) + } + + (*context.TemplateData)["Latest"] = updates[0] + return success(context, req, resp) + } +}