package api import ( "html/template" "log/slog" "net/http" "time" "git.maximotejeda.com/maximo/us-dop-api/domain" "git.maximotejeda.com/maximo/us-dop-api/ports" ) type API struct { http.ServeMux dolar ports.DolarService log *slog.Logger templ template.Template } type SearchResult struct { InstRequested string `json:"institution_requested"` Date time.Time `json:"date"` TimeAmount string `json:"time_amount"` TimeFrame string `json:"time_frame"` Results []*domain.History `josn:"results"` } func NewApiHandler( dolar ports.DolarService, log *slog.Logger, templ template.Template) *API { log = log.With("api", "insti") api := &API{ log: log, dolar: dolar, templ: templ, } api.HandleFunc("POST /api/instituciones/history", api.GetInstitutionHistory) // general handler to get banks, agents and others histories // api.HandleFunc("GET /api/instituciones/{inst}", nil) // return the card of just one institution with details api.HandleFunc("GET /api/{inst}/", api.GetInstNames) api.HandleFunc("GET /api/latest/all", api.GetAllLatestPrice) api.HandleFunc("GET /api/control/select", api.GetHistoryPage) api.HandleFunc("GET /api/control/compare", api.GetComparisonPage) return api } // instParseHTML // // Can be much tipe of html part of a list, a form, a card etc... func instParseHTML(SearchResult) string { return "html" }