diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2025-01-05 16:55:49 -0800 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2025-01-05 16:55:49 -0800 |
commit | 66df8b0e86f76fa3154ac9fad880d022c6c7843e (patch) | |
tree | 52894bb87eb9494d282e2a1a9a9399ac85cc4e18 | |
parent | d25ec27fb1c3df175e1b98af1fdc26881d68a1ab (diff) | |
download | whois-66df8b0e86f76fa3154ac9fad880d022c6c7843e.tar.gz whois-66df8b0e86f76fa3154ac9fad880d022c6c7843e.zip |
fix whois gitignore
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | api/whois/whois.go | 28 |
2 files changed, 30 insertions, 1 deletions
@@ -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) + } +} |