rotas no back
This commit is contained in:
@@ -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:])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user