This commit is contained in:
parent
d25ec27fb1
commit
66df8b0e86
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
*.env
|
*.env
|
||||||
whois
|
*whois
|
||||||
|
!*whois/
|
||||||
*.db
|
*.db
|
||||||
|
28
api/whois/whois.go
Normal file
28
api/whois/whois.go
Normal file
@ -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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user