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

mishankov / platforma / 18816060973

26 Oct 2025 09:30AM UTC coverage: 9.617% (+0.04%) from 9.581%
18816060973

Pull #9

github

mishankov
ci: add additional linters and enforce HTTP method constants in tests

- Add tagliatelle, testableexamples, testpackage, thelper, tparallel, unconvert, unparam, unused, and usestdlibvars linters to golangci configuration
- Configure tagliatelle to enforce camelCase for JSON tags
- Replace string literals with http.Method constants in test files for improved code quality and consistency
- Update HTTP method usage in auth middleware and httpclient tests to use standard library constants
Pull Request #9: Linter configuration

11 of 42 new or added lines in 7 files covered. (26.19%)

69 existing lines in 7 files now uncovered.

98 of 1019 relevant lines covered (9.62%)

0.33 hits per line

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

21.15
/httpserver/httpserver.go
1
package httpserver
2

3
import (
4
        "context"
5
        "errors"
6
        "net/http"
7
        "os"
8
        "os/signal"
9
        "syscall"
10
        "time"
11

12
        "github.com/mishankov/platforma/log"
13
)
14

15
type HttpServer struct {
16
        mux             *http.ServeMux
17
        port            string
18
        shutdownTimeout time.Duration
19
        middlewares     []Middleware
20
}
21

22
func New(port string, shutdownTimeout time.Duration) *HttpServer {
3✔
23
        return &HttpServer{mux: http.NewServeMux(), port: port, shutdownTimeout: shutdownTimeout}
3✔
24
}
3✔
25

26
func (s *HttpServer) Handle(pattern string, handler http.Handler) {
3✔
27
        s.mux.Handle(pattern, handler)
3✔
28
}
3✔
29

UNCOV
30
func (s *HttpServer) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request)) {
×
31
        s.mux.HandleFunc(pattern, http.HandlerFunc(handler))
×
32
}
×
33

UNCOV
34
func (s *HttpServer) HandleGroup(pattern string, handler http.Handler) {
×
35
        s.mux.Handle(pattern+"/", http.StripPrefix(pattern, handler))
×
36
}
×
37

UNCOV
38
func (s *HttpServer) Use(middlewares ...Middleware) {
×
39
        s.middlewares = append(s.middlewares, middlewares...)
×
40
}
×
41

UNCOV
42
func (s *HttpServer) UseFunc(middlewareFuncs ...func(http.Handler) http.Handler) {
×
43
        for _, middlewareFunc := range middlewareFuncs {
×
44
                s.middlewares = append(s.middlewares, MiddlewareFunc(middlewareFunc))
×
45
        }
×
46
}
47

UNCOV
48
func (s *HttpServer) Run(ctx context.Context) error {
×
49
        server := &http.Server{
×
NEW
50
                Addr:              ":" + s.port,
×
NEW
51
                Handler:           wrapHandlerInMiddleware(s.mux, s.middlewares),
×
NEW
52
                ReadHeaderTimeout: 1 * time.Second,
×
53
        }
×
54

×
55
        go func() {
×
56
                log.InfoContext(ctx, "starting http server", "address", server.Addr)
×
57

×
58
                if err := server.ListenAndServe(); !errors.Is(err, http.ErrServerClosed) {
×
59
                        log.ErrorContext(ctx, "HTTP server error", "error", err)
×
60
                }
×
61
                log.InfoContext(ctx, "stopped serving new connections.")
×
62
        }()
63

UNCOV
64
        sigChan := make(chan os.Signal, 1)
×
65
        signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
×
66
        <-sigChan
×
67

×
68
        shutdownCtx, shutdownRelease := context.WithTimeout(ctx, s.shutdownTimeout)
×
69
        defer shutdownRelease()
×
70

×
71
        if err := server.Shutdown(shutdownCtx); err != nil {
×
72
                log.ErrorContext(ctx, "HTTP shutdown error", "error", err)
×
73
                return err
×
74
        }
×
75
        log.InfoContext(ctx, "graceful shutdown completed.")
×
76

×
77
        return nil
×
78
}
79

80
func (s *HttpServer) Healthcheck(ctx context.Context) any {
3✔
81
        return map[string]any{
3✔
82
                "port": s.port,
3✔
83
        }
3✔
84
}
3✔
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