rotas no back

This commit is contained in:
2026-10-22 00:11:59 -03:00
parent 94920e9825
commit c68d12f4a7
5 changed files with 126 additions and 54 deletions

View File

@@ -4,6 +4,7 @@ import (
"database/sql"
"encoding/json"
"net/http"
"strconv"
"time"
mw "github.com/weltonmoura/initpage/internal/middleware"
@@ -34,7 +35,7 @@ func (s *Sync) Get(w http.ResponseWriter, r *http.Request) {
return
}
w.Header().Set("Content-Type", "application/json")
w.Write([]byte(`{"data":` + data + `,"version":` + itoa(version) + `}`))
w.Write([]byte(`{"data":` + data + `,"version":` + strconv.Itoa(version) + `}`))
}
func (s *Sync) Put(w http.ResponseWriter, r *http.Request) {
@@ -70,22 +71,3 @@ func (s *Sync) Put(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Write([]byte(`{"ok":true}`))
}
func itoa(i int) string {
if i == 0 {
return "0"
}
sign := ""
if i < 0 {
sign = "-"
i = -i
}
b := [12]byte{}
n := len(b)
for i > 0 {
n--
b[n] = byte('0' + i%10)
i /= 10
}
return sign + string(b[n:])
}