• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

joohoi / acme-dns / 21649486448

03 Feb 2026 09:59PM UTC coverage: 77.593% (+4.3%) from 73.276%
21649486448

Pull #325

github

joohoi
Fix linter and umask setting
Pull Request #325: Refactoring

578 of 754 new or added lines in 20 files covered. (76.66%)

3 existing lines in 1 file now uncovered.

793 of 1022 relevant lines covered (77.59%)

7.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

77.5
/pkg/api/update.go
1
package api
2

3
import (
4
        "net/http"
5

6
        "github.com/joohoi/acme-dns/pkg/acmedns"
7

8
        "github.com/julienschmidt/httprouter"
9
)
10

11
func (a *AcmednsAPI) webUpdatePost(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
12✔
12
        var updStatus int
12✔
13
        var upd []byte
12✔
14
        // Get user
12✔
15
        atxt, ok := r.Context().Value(ACMETxtKey).(acmedns.ACMETxt)
12✔
16
        if !ok {
12✔
NEW
17
                a.Logger.Errorw("Context error",
×
NEW
18
                        "error", "context")
×
NEW
19
        }
×
20
        // NOTE: An invalid subdomain should not happen - the auth handler should
21
        // reject POSTs with an invalid subdomain before this handler. Reject any
22
        // invalid subdomains anyway as a matter of caution.
23
        if !validSubdomain(atxt.Subdomain) {
12✔
NEW
24
                a.Logger.Errorw("Bad update data",
×
NEW
25
                        "error", "subdomain",
×
NEW
26
                        "subdomain", atxt.Subdomain,
×
NEW
27
                        "txt", atxt.Value)
×
NEW
28
                updStatus = http.StatusBadRequest
×
NEW
29
                upd = jsonError("bad_subdomain")
×
30
        } else if !validTXT(atxt.Value) {
15✔
31
                a.Logger.Errorw("Bad update data",
3✔
32
                        "error", "txt",
3✔
33
                        "subdomain", atxt.Subdomain,
3✔
34
                        "txt", atxt.Value)
3✔
35
                updStatus = http.StatusBadRequest
3✔
36
                upd = jsonError("bad_txt")
3✔
37
        } else if validSubdomain(atxt.Subdomain) && validTXT(atxt.Value) {
21✔
38
                err := a.DB.Update(atxt.ACMETxtPost)
9✔
39
                if err != nil {
10✔
40
                        a.Logger.Errorw("Error while trying to update record",
1✔
41
                                "error", err.Error())
1✔
42
                        updStatus = http.StatusInternalServerError
1✔
43
                        upd = jsonError("db_error")
1✔
44
                } else {
9✔
45
                        a.Logger.Debugw("TXT record updated",
8✔
46
                                "subdomain", atxt.Subdomain,
8✔
47
                                "txt", atxt.Value)
8✔
48
                        updStatus = http.StatusOK
8✔
49
                        upd = []byte("{\"txt\": \"" + atxt.Value + "\"}")
8✔
50
                }
8✔
51
        }
52
        w.Header().Set("Content-Type", "application/json")
12✔
53
        w.WriteHeader(updStatus)
12✔
54
        _, _ = w.Write(upd)
12✔
55
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc