mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
@ -2,6 +2,10 @@ package v1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
conf "github.com/muety/wakapi/config"
|
||||
"github.com/muety/wakapi/models"
|
||||
@ -9,9 +13,6 @@ import (
|
||||
"github.com/muety/wakapi/services"
|
||||
"github.com/muety/wakapi/utils"
|
||||
"github.com/patrickmn/go-cache"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -50,7 +51,7 @@ func (h *BadgeHandler) RegisterRoutes(router *mux.Router) {
|
||||
// @Param interval path string true "Interval to aggregate data for" Enums(today, yesterday, week, month, year, 7_days, last_7_days, 30_days, last_30_days, 12_months, last_12_months, any)
|
||||
// @Param filter path string true "Filter to apply (e.g. 'project:wakapi' or 'language:Go')"
|
||||
// @Success 200 {object} v1.BadgeData
|
||||
// @Router /api/compat/shields/v1/{user}/{interval}/{filter} [get]
|
||||
// @Router /compat/shields/v1/{user}/{interval}/{filter} [get]
|
||||
func (h *BadgeHandler) Get(w http.ResponseWriter, r *http.Request) {
|
||||
intervalReg := regexp.MustCompile(intervalPattern)
|
||||
entityFilterReg := regexp.MustCompile(entityFilterPattern)
|
||||
|
@ -1,6 +1,10 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
conf "github.com/muety/wakapi/config"
|
||||
"github.com/muety/wakapi/middlewares"
|
||||
@ -9,9 +13,6 @@ import (
|
||||
routeutils "github.com/muety/wakapi/routes/utils"
|
||||
"github.com/muety/wakapi/services"
|
||||
"github.com/muety/wakapi/utils"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
)
|
||||
|
||||
type AllTimeHandler struct {
|
||||
@ -44,7 +45,7 @@ func (h *AllTimeHandler) RegisterRoutes(router *mux.Router) {
|
||||
// @Param user path string true "User ID to fetch data for (or 'current')"
|
||||
// @Security ApiKeyAuth
|
||||
// @Success 200 {object} v1.AllTimeViewModel
|
||||
// @Router /api/compat/wakatime/v1/users/{user}/all_time_since_today [get]
|
||||
// @Router /compat/wakatime/v1/users/{user}/all_time_since_today [get]
|
||||
func (h *AllTimeHandler) Get(w http.ResponseWriter, r *http.Request) {
|
||||
values, _ := url.ParseQuery(r.URL.RawQuery)
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
conf "github.com/muety/wakapi/config"
|
||||
"github.com/muety/wakapi/middlewares"
|
||||
@ -9,8 +12,6 @@ import (
|
||||
routeutils "github.com/muety/wakapi/routes/utils"
|
||||
"github.com/muety/wakapi/services"
|
||||
"github.com/muety/wakapi/utils"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ProjectsHandler struct {
|
||||
@ -44,7 +45,7 @@ func (h *ProjectsHandler) RegisterRoutes(router *mux.Router) {
|
||||
// @Param q query string true "Query to filter projects by"
|
||||
// @Security ApiKeyAuth
|
||||
// @Success 200 {object} v1.ProjectsViewModel
|
||||
// @Router /api/compat/wakatime/v1/users/{user}/projects [get]
|
||||
// @Router /compat/wakatime/v1/users/{user}/projects [get]
|
||||
func (h *ProjectsHandler) Get(w http.ResponseWriter, r *http.Request) {
|
||||
user, err := routeutils.CheckEffectiveUser(w, r, h.userSrvc, "current")
|
||||
if err != nil {
|
||||
|
@ -1,6 +1,9 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
conf "github.com/muety/wakapi/config"
|
||||
"github.com/muety/wakapi/middlewares"
|
||||
@ -8,8 +11,6 @@ import (
|
||||
v1 "github.com/muety/wakapi/models/compat/wakatime/v1"
|
||||
"github.com/muety/wakapi/services"
|
||||
"github.com/muety/wakapi/utils"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
type StatsHandler struct {
|
||||
@ -50,7 +51,7 @@ func (h *StatsHandler) RegisterRoutes(router *mux.Router) {
|
||||
// @Param range path string false "Range interval identifier" Enums(today, yesterday, week, month, year, 7_days, last_7_days, 30_days, last_30_days, 12_months, last_12_months, any)
|
||||
// @Security ApiKeyAuth
|
||||
// @Success 200 {object} v1.StatsViewModel
|
||||
// @Router /api/compat/wakatime/v1/users/{user}/stats/{range} [get]
|
||||
// @Router /compat/wakatime/v1/users/{user}/stats/{range} [get]
|
||||
func (h *StatsHandler) Get(w http.ResponseWriter, r *http.Request) {
|
||||
var vars = mux.Vars(r)
|
||||
var authorizedUser, requestedUser *models.User
|
||||
|
@ -52,7 +52,7 @@ func (h *StatusBarHandler) RegisterRoutes(router *mux.Router) {
|
||||
// @Param user path string true "User ID to fetch data for (or 'current')"
|
||||
// @Security ApiKeyAuth
|
||||
// @Success 200 {object} StatusBarViewModel
|
||||
// @Router /api/users/{user}/statusbar/today [get]
|
||||
// @Router /users/{user}/statusbar/today [get]
|
||||
func (h *StatusBarHandler) Get(w http.ResponseWriter, r *http.Request) {
|
||||
user, err := routeutils.CheckEffectiveUser(w, r, h.userSrvc, "current")
|
||||
if err != nil {
|
||||
|
@ -2,6 +2,10 @@ package v1
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
conf "github.com/muety/wakapi/config"
|
||||
"github.com/muety/wakapi/middlewares"
|
||||
@ -10,9 +14,6 @@ import (
|
||||
routeutils "github.com/muety/wakapi/routes/utils"
|
||||
"github.com/muety/wakapi/services"
|
||||
"github.com/muety/wakapi/utils"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type SummariesHandler struct {
|
||||
@ -53,7 +54,7 @@ func (h *SummariesHandler) RegisterRoutes(router *mux.Router) {
|
||||
// @Param end query string false "End date (e.g. '2021-02-08')"
|
||||
// @Security ApiKeyAuth
|
||||
// @Success 200 {object} v1.SummariesViewModel
|
||||
// @Router /api/compat/wakatime/v1/users/{user}/summaries [get]
|
||||
// @Router /compat/wakatime/v1/users/{user}/summaries [get]
|
||||
func (h *SummariesHandler) Get(w http.ResponseWriter, r *http.Request) {
|
||||
_, err := routeutils.CheckEffectiveUser(w, r, h.userSrvc, "current")
|
||||
if err != nil {
|
||||
|
@ -1,6 +1,8 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
conf "github.com/muety/wakapi/config"
|
||||
"github.com/muety/wakapi/middlewares"
|
||||
@ -8,7 +10,6 @@ import (
|
||||
routeutils "github.com/muety/wakapi/routes/utils"
|
||||
"github.com/muety/wakapi/services"
|
||||
"github.com/muety/wakapi/utils"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type UsersHandler struct {
|
||||
@ -41,7 +42,7 @@ func (h *UsersHandler) RegisterRoutes(router *mux.Router) {
|
||||
// @Param user path string true "User ID to fetch (or 'current')"
|
||||
// @Security ApiKeyAuth
|
||||
// @Success 200 {object} v1.UserViewModel
|
||||
// @Router /api/compat/wakatime/v1/users/{user} [get]
|
||||
// @Router /compat/wakatime/v1/users/{user} [get]
|
||||
func (h *UsersHandler) Get(w http.ResponseWriter, r *http.Request) {
|
||||
wakapiUser, err := routeutils.CheckEffectiveUser(w, r, h.userSrvc, "current")
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user