api: Add go files
I know this is a huge commit, but I can't be bothered to check this in part by part.
This commit is contained in:
29
api/domain_get.go
Normal file
29
api/domain_get.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import ()
|
||||
|
||||
func domainGet(dmn string) (domain, error) {
|
||||
if dmn == "" {
|
||||
return domain{}, errorMissingField
|
||||
}
|
||||
|
||||
statement := `
|
||||
SELECT domain, ownerHex, name, creationDate, state, importedComments, autoSpamFilter, requireModeration, requireIdentification
|
||||
FROM domains
|
||||
WHERE domain = $1;
|
||||
`
|
||||
row := db.QueryRow(statement, dmn)
|
||||
|
||||
var err error
|
||||
d := domain{}
|
||||
if err = row.Scan(&d.Domain, &d.OwnerHex, &d.Name, &d.CreationDate, &d.State, &d.ImportedComments, &d.AutoSpamFilter, &d.RequireModeration, &d.RequireIdentification); err != nil {
|
||||
return d, errorNoSuchDomain
|
||||
}
|
||||
|
||||
d.Moderators, err = domainModeratorList(d.Domain)
|
||||
if err != nil {
|
||||
return domain{}, err
|
||||
}
|
||||
|
||||
return d, nil
|
||||
}
|
||||
Reference in New Issue
Block a user