36 lines
914 B
Go
36 lines
914 B
Go
package web
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
func (s *Server) handleListDirty(w http.ResponseWriter, r *http.Request) {
|
|
modules, err := s.Engine.DirtyList(r.Context(), s.DB)
|
|
if err != nil {
|
|
writeError(w, http.StatusInternalServerError, err.Error())
|
|
return
|
|
}
|
|
writeJSON(w, http.StatusOK, map[string]any{"modules": modules})
|
|
}
|
|
|
|
func (s *Server) handleApply(w http.ResponseWriter, r *http.Request) {
|
|
result, err := s.Engine.ApplyAll(r.Context(), s.DB)
|
|
if err != nil {
|
|
writeJSON(w, http.StatusInternalServerError, map[string]any{
|
|
"error": err.Error(),
|
|
"results": result.Results,
|
|
})
|
|
return
|
|
}
|
|
writeJSON(w, http.StatusOK, result)
|
|
}
|
|
|
|
func (s *Server) handleApplyLog(w http.ResponseWriter, r *http.Request) {
|
|
entries, err := s.DB.ListApplyLog(100)
|
|
if err != nil {
|
|
writeError(w, http.StatusInternalServerError, err.Error())
|
|
return
|
|
}
|
|
writeJSON(w, http.StatusOK, map[string]any{"entries": entries})
|
|
}
|