|
|
|
|
|
|
|
|
{"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 { |