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

joohoi / acme-dns / 21649894913

03 Feb 2026 10:13PM UTC coverage: 77.593% (+4.3%) from 73.276%
21649894913

Pull #325

github

web-flow
Merge c6826aad3 into b7a0a8a7b
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%)

14.46 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) {
24✔
12
        var updStatus int
24✔
13
        var upd []byte
24✔
14
        // Get user
24✔
15
        atxt, ok := r.Context().Value(ACMETxtKey).(acmedns.ACMETxt)
24✔
16
        if !ok {
24✔
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) {
24✔
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) {
30✔
31
                a.Logger.Errorw("Bad update data",
6✔
32
                        "error", "txt",
6✔
33
                        "subdomain", atxt.Subdomain,
6✔
34
                        "txt", atxt.Value)
6✔
35
                updStatus = http.StatusBadRequest
6✔
36
                upd = jsonError("bad_txt")
6✔
37
        } else if validSubdomain(atxt.Subdomain) && validTXT(atxt.Value) {
42✔
38
                err := a.DB.Update(atxt.ACMETxtPost)
18✔
39
                if err != nil {
20✔
40
                        a.Logger.Errorw("Error while trying to update record",
2✔
41
                                "error", err.Error())
2✔
42
                        updStatus = http.StatusInternalServerError
2✔
43
                        upd = jsonError("db_error")
2✔
44
                } else {
18✔
45
                        a.Logger.Debugw("TXT record updated",
16✔
46
                                "subdomain", atxt.Subdomain,
16✔
47
                                "txt", atxt.Value)
16✔
48
                        updStatus = http.StatusOK
16✔
49
                        upd = []byte("{\"txt\": \"" + atxt.Value + "\"}")
16✔
50
                }
16✔
51
        }
52
        w.Header().Set("Content-Type", "application/json")
24✔
53
        w.WriteHeader(updStatus)
24✔
54
        _, _ = w.Write(upd)
24✔
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