Add api endpoints for UI
This commit is contained in:
24
updates/api.go
Normal file
24
updates/api.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package updates
|
||||
|
||||
import (
|
||||
"github.com/safing/portbase/api"
|
||||
)
|
||||
|
||||
const (
|
||||
apiPathCheckForUpdates = "updates/check"
|
||||
)
|
||||
|
||||
func registerAPIEndpoints() error {
|
||||
return api.RegisterEndpoint(api.Endpoint{
|
||||
Path: apiPathCheckForUpdates,
|
||||
Read: api.PermitUser,
|
||||
ActionFunc: func(_ *api.Request) (msg string, err error) {
|
||||
if err := TriggerUpdate(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return "triggered update check", nil
|
||||
},
|
||||
Name: "Check for Updates",
|
||||
Description: "Triggers checking for updates.",
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user