mirror of
https://github.com/navidrome/navidrome.git
synced 2025-08-10 00:52:20 +00:00
Implemented common parameter validation
This commit is contained in:
@@ -13,6 +13,15 @@ func (c *BaseAPIController) NewEmpty() responses.Subsonic {
|
||||
return responses.Subsonic{Status: "ok", Version: beego.AppConfig.String("apiVersion")}
|
||||
}
|
||||
|
||||
func (c *BaseAPIController) ValidateParameters(param string, msg string) string {
|
||||
p := c.Input().Get(param)
|
||||
if p == "" {
|
||||
c.SendError(responses.ERROR_MISSING_PARAMETER, msg)
|
||||
}
|
||||
c.Data[param] = p
|
||||
return p
|
||||
}
|
||||
|
||||
func (c *BaseAPIController) SendError(errorCode int, message ...interface{}) {
|
||||
response := responses.Subsonic{Version: beego.AppConfig.String("apiVersion"), Status: "fail"}
|
||||
var msg string
|
||||
|
||||
Reference in New Issue
Block a user