Re-struct pkg/api, pkg/database

This commit is contained in:
2021-12-07 00:19:05 +08:00
parent be2515231c
commit 258bf9869f
25 changed files with 1350 additions and 1192 deletions

17
pkg/api/check.go Normal file
View File

@@ -0,0 +1,17 @@
package api
import (
"errors"
"log"
"net/http"
)
func (api *API) CheckLimit(w http.ResponseWriter, r *http.Request, limit int64) error {
if limit <= 0 || limit > 10 {
log.Println("[api] [Warning] Limit error", limit)
err := errors.New(`"limit" can't be zero or more than 10`)
api.HandleError(w, r, err)
return err
}
return nil
}