FIX lint
Some checks failed
dev test / test (push) Successful in 7s
dev test / vulnCheck (push) Successful in 12s
dev test / Ci-Lint (push) Successful in 10s
${{ github.actor }} executed Build Push Prod / build (push) Failing after 42s
${{ github.actor }} executed Build Push Prod / deploy (push) Has been skipped

This commit is contained in:
maximo tejeda 2024-12-03 22:30:32 -04:00
parent e9a9fb1ddc
commit eeebd4c25c
6 changed files with 16 additions and 14 deletions

View File

@ -9,7 +9,7 @@ COPY . .
RUN go build -o bin/us-dop-api \ RUN go build -o bin/us-dop-api \
-ldflags "-X main.Shortsha=${SHORTSHA} \ -ldflags "-X main.Shortsha=${SHORTSHA} \
-X main.Version=${version} \ -X main.Version=${version} \
-X main.Aarch=${TARGETARCH}" ./cmd -X main.Aarch=${TARGETARCH}" ./cmd/api/main.go
FROM alpine AS runner FROM alpine AS runner
WORKDIR /app WORKDIR /app

View File

@ -1,7 +1,6 @@
package main package main
import ( import (
"html/template"
"io/fs" "io/fs"
"log/slog" "log/slog"
"net/http" "net/http"
@ -21,7 +20,7 @@ import (
var ( var (
hostSTR = os.Getenv("HOST)") hostSTR = os.Getenv("HOST)")
portSTR = os.Getenv("PORT") portSTR = os.Getenv("PORT")
templ template.Template
) )
func main() { func main() {

View File

@ -45,6 +45,6 @@ func NewApiHandler( dolar ports.DolarService, log *slog.Logger, templ template.T
// instParseHTML // instParseHTML
// //
// Can be much tipe of html part of a list, a form, a card etc... // Can be much tipe of html part of a list, a form, a card etc...
func instParseHTML(SearchResult) string { /* func instParseHTML(SearchResult) string {
return "html" return "html"
} }*/

View File

@ -3,9 +3,9 @@ package api
import "net/http" import "net/http"
func (api *API) GetHistoryPage(w http.ResponseWriter, r *http.Request) { func (api *API) GetHistoryPage(w http.ResponseWriter, r *http.Request) {
api.templ.ExecuteTemplate(w, "hist-page", nil) _ = api.templ.ExecuteTemplate(w, "hist-page", nil)
} }
func (api *API) GetComparisonPage(w http.ResponseWriter, r *http.Request) { func (api *API) GetComparisonPage(w http.ResponseWriter, r *http.Request) {
api.templ.ExecuteTemplate(w, "compare-page", nil) _ = api.templ.ExecuteTemplate(w, "compare-page", nil)
} }

View File

@ -98,7 +98,7 @@ func (api *API) GetInstitutionHistory(w http.ResponseWriter, r *http.Request) {
} }
} else { } else {
data, _ := json.Marshal(searchRes) data, _ := json.Marshal(searchRes)
w.Write(data) _, _ = w.Write(data)
} }
} }
@ -115,7 +115,10 @@ func (api *API) GetInstNames(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Etag", "institutions") w.Header().Set("Etag", "institutions")
w.Header().Set("Cache-Control", "max-age=3600") w.Header().Set("Cache-Control", "max-age=3600")
var institutions, err = []string{}, *new(error) var (
institutions []string
err = *new(error)
)
switch inst { switch inst {
case "bancos", "banco": case "bancos", "banco":
inst = "bancos" inst = "bancos"
@ -179,7 +182,7 @@ func (api *API) GetInstNames(w http.ResponseWriter, r *http.Request) {
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
w.Write(dat) _, _ = w.Write(dat)
} }
} }
@ -194,7 +197,7 @@ func (api *API) GetLatestPrice(w http.ResponseWriter, r *http.Request) {
api.log.Error("geting latest price", "error", err) api.log.Error("geting latest price", "error", err)
http.NotFound(w, r) http.NotFound(w, r)
} }
api.templ.ExecuteTemplate(w, "latest-price", price) _ = api.templ.ExecuteTemplate(w, "latest-price", price)
} }
func (api *API) GetAllLatestPrice(w http.ResponseWriter, r *http.Request) { func (api *API) GetAllLatestPrice(w http.ResponseWriter, r *http.Request) {
@ -222,5 +225,5 @@ func (api *API) GetAllLatestPrice(w http.ResponseWriter, r *http.Request) {
} }
instLastPriceList = append(instLastPriceList, in) instLastPriceList = append(instLastPriceList, in)
} }
api.templ.ExecuteTemplate(w, "latest-price", instLastPriceList) _ = api.templ.ExecuteTemplate(w, "latest-price", instLastPriceList)
} }

View File

@ -39,7 +39,7 @@ func NewRoot(dolar ports.DolarService, log *slog.Logger, files []string) *Root {
} }
r.HandleFunc("/{$}", func(w http.ResponseWriter, r *http.Request) { r.HandleFunc("/{$}", func(w http.ResponseWriter, r *http.Request) {
templ.ExecuteTemplate(w, "index", nil) _ = templ.ExecuteTemplate(w, "index", nil)
//w.Write([]byte("{'status': 'ok'}")) //w.Write([]byte("{'status': 'ok'}"))
}) })
inst := api.NewApiHandler( dolar, log, templ) inst := api.NewApiHandler( dolar, log, templ)
@ -51,7 +51,7 @@ func NewRoot(dolar ports.DolarService, log *slog.Logger, files []string) *Root {
// telegram // telegram
r.HandleFunc("/telegram/{$}", func(w http.ResponseWriter, r *http.Request) { r.HandleFunc("/telegram/{$}", func(w http.ResponseWriter, r *http.Request) {
templ.ExecuteTemplate(w, "index", nil) _ = templ.ExecuteTemplate(w, "index", nil)
//w.Write([]byte("{'status': 'ok'}")) //w.Write([]byte("{'status': 'ok'}"))
}) })