mirror of
https://github.com/donl/gPanel.git
synced 2026-05-26 06:12:20 -06:00
28 lines
784 B
Go
28 lines
784 B
Go
// Package api handles all API calls
|
|
package api
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/Ennovar/gPanel/pkg/api/user"
|
|
)
|
|
|
|
// HandleAPI function takes a path and determines if it is an API call, if it is it will
|
|
// call the specified API. It returns two booleans, the first being if it is an API call and
|
|
// the second is the response of the API call's function.
|
|
func HandleAPI(path string, res http.ResponseWriter, req *http.Request) (bool, bool) {
|
|
splitUrl := strings.Split(path, "/")
|
|
suspectApi := strings.ToLower(splitUrl[len(splitUrl)-1])
|
|
|
|
switch suspectApi {
|
|
case "user_auth":
|
|
return true, user.Auth(res, req)
|
|
case "user_register":
|
|
return true, user.Register(res, req)
|
|
case "user_logout":
|
|
return true, user.Logout(res, req)
|
|
default:
|
|
return false, false
|
|
}
|
|
}
|