Windows system utility with driver scanning, Windows Update integration, and system info collection. Beautiful dark-themed UI via embedded WebView2. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
60 lines
1.4 KiB
Go
60 lines
1.4 KiB
Go
package bridge
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/mumur/driver-booster/internal/drivers"
|
|
"github.com/mumur/driver-booster/internal/sysinfo"
|
|
"github.com/mumur/driver-booster/internal/winupdate"
|
|
)
|
|
|
|
type Bridge struct {
|
|
DriverScanner *drivers.Scanner
|
|
UpdateChecker *winupdate.Checker
|
|
SysInfo *sysinfo.Collector
|
|
}
|
|
|
|
func New(ds *drivers.Scanner, uc *winupdate.Checker, si *sysinfo.Collector) *Bridge {
|
|
return &Bridge{
|
|
DriverScanner: ds,
|
|
UpdateChecker: uc,
|
|
SysInfo: si,
|
|
}
|
|
}
|
|
|
|
func jsonResponse(w http.ResponseWriter, data interface{}) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
}
|
|
|
|
func (b *Bridge) HandleSysInfo(w http.ResponseWriter, r *http.Request) {
|
|
info := b.SysInfo.Collect()
|
|
jsonResponse(w, info)
|
|
}
|
|
|
|
func (b *Bridge) HandleDrivers(w http.ResponseWriter, r *http.Request) {
|
|
result := b.DriverScanner.Scan()
|
|
jsonResponse(w, result)
|
|
}
|
|
|
|
func (b *Bridge) HandleDriverScan(w http.ResponseWriter, r *http.Request) {
|
|
result := b.DriverScanner.Scan()
|
|
jsonResponse(w, result)
|
|
}
|
|
|
|
func (b *Bridge) HandleUpdates(w http.ResponseWriter, r *http.Request) {
|
|
result := b.UpdateChecker.Check()
|
|
jsonResponse(w, result)
|
|
}
|
|
|
|
func (b *Bridge) HandleUpdateCheck(w http.ResponseWriter, r *http.Request) {
|
|
result := b.UpdateChecker.Check()
|
|
jsonResponse(w, result)
|
|
}
|
|
|
|
func (b *Bridge) HandleUpdateInstall(w http.ResponseWriter, r *http.Request) {
|
|
result := b.UpdateChecker.Install(nil)
|
|
jsonResponse(w, result)
|
|
}
|