Sfoglia il codice sorgente

avatar added

master
sp 4 anni fa
parent
commit
27c30a6abb
4 ha cambiato i file con 156 aggiunte e 2 eliminazioni
  1. +102
    -0
      apiV1Avatar.go
  2. +37
    -0
      apiV1GridLoanFullOverview.go
  3. +6
    -1
      apiv1.go
  4. +11
    -1
      config.go

+ 102
- 0
apiV1Avatar.go
File diff soppresso perché troppo grande
Vedi File


+ 37
- 0
apiV1GridLoanFullOverview.go Vedi File

package main

import (
"biukop.com/sfm/loan"
log "github.com/sirupsen/logrus"
"net/http"
"strconv"
)

func apiV1GridLoanFullOverview(w http.ResponseWriter, r *http.Request, ss *loan.Session) {

var skip int = 0
var take int = 0
var sort = r.URL.Query().Get("$orderby") //

sSkip := r.URL.Query().Get("$skip") //
if sSkip == "" {
log.Info("query full_loan_summary, skip not present set to 0 ")
} else {
s, err := strconv.Atoi(sSkip) // for weird reasons, I cannot replace s with skip
log.Print(s, err)
skip = s
}

sTake := r.URL.Query().Get("$top") //
if sTake == "" {
log.Info("query full_loan_summary, take not present set to 0 ")
} else {
t, err := strconv.Atoi(sTake)
log.Print(t, err)
take = t
}

data := loan.QFullLLoanSummary(skip, take, sort)
//send out
apiV1SendJson(data, w, r, ss)
}

+ 6
- 1
apiv1.go Vedi File

{"GET", "chart/past-year-monthly", apiV1ChartPastYearMonthly}, {"GET", "chart/past-year-monthly", apiV1ChartPastYearMonthly},
{"GET", "chart/recent-10-loans", apiV1ChartRecent10Loans}, {"GET", "chart/recent-10-loans", apiV1ChartRecent10Loans},
{"GET", "chart/top-broker", apiV1ChartTopBroker}, {"GET", "chart/top-broker", apiV1ChartTopBroker},
{"GET", "grid/loan/full-loan-overview", apiV1GridLoanFullOverview},
{"GET", "avatar/", apiV1Avatar},
{"GET", "login", apiV1DumpRequest}, {"GET", "login", apiV1DumpRequest},
} }
} else { //production } else { //production
{"GET", "chart/past-year-monthly", apiV1ChartPastYearMonthly}, {"GET", "chart/past-year-monthly", apiV1ChartPastYearMonthly},
{"GET", "chart/recent-10-loans", apiV1ChartRecent10Loans}, {"GET", "chart/recent-10-loans", apiV1ChartRecent10Loans},
{"GET", "chart/top-broker", apiV1ChartTopBroker}, {"GET", "chart/top-broker", apiV1ChartTopBroker},
{"GET", "grid/loan/full-loan-overview", apiV1GridLoanFullOverview},
{"GET", "avatar/", apiV1Avatar},
{"GET", "login", apiV1EmptyResponse}, {"GET", "login", apiV1EmptyResponse},
} }
} }
//search through handler //search through handler
path := r.URL.Path[len(apiV1Prefix):] //strip API prefix path := r.URL.Path[len(apiV1Prefix):] //strip API prefix
for _, node := range apiV1Handler { for _, node := range apiV1Handler {
if (r.Method == node.Method || node.Method == "*") && path == node.Path {
log.Println(node, path, strings.HasPrefix(path, node.Path))
if (r.Method == node.Method || node.Method == "*") && strings.HasPrefix(path, node.Path) {
node.Handler(w, r, &session) node.Handler(w, r, &session)
e := session.Write() //finish this session to DB e := session.Write() //finish this session to DB
if e != nil { if e != nil {

+ 11
- 1
config.go Vedi File

"encoding/json" "encoding/json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"io/ioutil" "io/ioutil"
"strings"
) )


type configStaticHtml struct { type configStaticHtml struct {
TlsKey string TlsKey string
Static []configStaticHtml Static []configStaticHtml
Debug bool Debug bool
Session struct {
Session struct { //TODO: figure what is this intended for
Guest bool Guest bool
Year int //how many years Year int //how many years
Month int //how many years Month int //how many years
//TODO: check config before proceed further //TODO: check config before proceed further
return return
} }

func (m *configuration) getAvatarPath() (ret string) {
for _, v := range m.Static {
if strings.ToLower(v.Dir) == "avatar" {
return v.Dir //found it
}
}
return ""
}

Loading…
Annulla
Salva