Skip to content
Snippets Groups Projects

Full MVC of gitlab-zoekt-indexer

Merged Dylan Griffith requested to merge add-new-api-paths into main
All threads resolved!
Compare and Show latest version
1 file
+ 16
7
Compare changes
  • Side-by-side
  • Inline
@@ -56,6 +56,11 @@ func (s *indexServer) createIndexDir() {
@@ -56,6 +56,11 @@ func (s *indexServer) createIndexDir() {
func (s *indexServer) handleStatus() http.HandlerFunc {
func (s *indexServer) handleStatus() http.HandlerFunc {
route := "status"
route := "status"
 
type response struct {
 
Success bool
 
SHA string
 
}
 
return func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
param := chi.URLParam(r, "id")
param := chi.URLParam(r, "id")
repoID, err := strconv.ParseUint(param, 10, 32)
repoID, err := strconv.ParseUint(param, 10, 32)
@@ -82,12 +87,12 @@ func (s *indexServer) handleStatus() http.HandlerFunc {
@@ -82,12 +87,12 @@ func (s *indexServer) handleStatus() http.HandlerFunc {
return
return
}
}
response := map[string]any{
resp := response{
"Success": true,
Success: true,
"SHA": currentSHA,
SHA: currentSHA,
}
}
s.respondWith(w, r, route, response)
s.respondWith(w, r, route, resp)
}
}
}
}
@@ -106,6 +111,10 @@ func (s *indexServer) decode(r *http.Request, v interface{}) error {
@@ -106,6 +111,10 @@ func (s *indexServer) decode(r *http.Request, v interface{}) error {
func (s *indexServer) handleIndex() http.HandlerFunc {
func (s *indexServer) handleIndex() http.HandlerFunc {
route := "index"
route := "index"
 
type response struct {
 
Success bool
 
}
 
parseRequest := func(r *http.Request) (indexRequest, error) {
parseRequest := func(r *http.Request) (indexRequest, error) {
var req indexRequest
var req indexRequest
err := s.decode(r, &req)
err := s.decode(r, &req)
@@ -138,11 +147,11 @@ func (s *indexServer) handleIndex() http.HandlerFunc {
@@ -138,11 +147,11 @@ func (s *indexServer) handleIndex() http.HandlerFunc {
return
return
}
}
response := map[string]any{
resp := response{
"Success": true,
Success: true,
}
}
s.respondWith(w, r, route, response)
s.respondWith(w, r, route, resp)
}
}
}
}
Loading