fix linter warnings
one method to add handlers
This commit is contained in:
9
apiGo/api/API.go
Normal file
9
apiGo/api/API.go
Normal file
@ -0,0 +1,9 @@
|
||||
package api
|
||||
|
||||
func AddHandlers() {
|
||||
addVideoHandlers()
|
||||
addSettingsHandlers()
|
||||
addTagHandlers()
|
||||
addActorsHandlers()
|
||||
addTvshowHandlers()
|
||||
}
|
@ -7,7 +7,7 @@ import (
|
||||
"openmediacenter/apiGo/database"
|
||||
)
|
||||
|
||||
func AddActorsHandlers() {
|
||||
func addActorsHandlers() {
|
||||
saveActorsToDB()
|
||||
getActorsFromDB()
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func AddSettingsHandlers() {
|
||||
func addSettingsHandlers() {
|
||||
saveSettingsToDB()
|
||||
getSettingsFromDB()
|
||||
reIndexHandling()
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"openmediacenter/apiGo/database"
|
||||
)
|
||||
|
||||
func AddTvshowHandlers() {
|
||||
func addTvshowHandlers() {
|
||||
// do not add handlers if tvshows not enabled
|
||||
if config.GetConfig().Features.DisableTVSupport {
|
||||
return
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func AddTagHandlers() {
|
||||
func addTagHandlers() {
|
||||
getFromDB()
|
||||
addToDB()
|
||||
deleteFromDB()
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func AddVideoHandlers() {
|
||||
func addVideoHandlers() {
|
||||
getVideoHandlers()
|
||||
loadVideosHandlers()
|
||||
addToVideoHandlers()
|
||||
|
@ -55,7 +55,10 @@ func callHandler(ctx *apicontext, handler func(ctx Context), writer http.Respons
|
||||
}
|
||||
}
|
||||
|
||||
func ServerInit() {
|
||||
func ServerInit(port uint16) error {
|
||||
// initialize auth service and add corresponding auth routes
|
||||
InitOAuth()
|
||||
|
||||
fmt.Printf("OpenMediacenter server up and running on port %d\n", port)
|
||||
return http.ListenAndServe(fmt.Sprintf(":%d", port), nil)
|
||||
}
|
||||
|
@ -2,19 +2,19 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"openmediacenter/apiGo/api"
|
||||
api2 "openmediacenter/apiGo/api/api"
|
||||
"openmediacenter/apiGo/config"
|
||||
"openmediacenter/apiGo/database"
|
||||
"openmediacenter/apiGo/static"
|
||||
"openmediacenter/apiGo/videoparser"
|
||||
"os"
|
||||
"os/signal"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("init OpenMediaCenter server")
|
||||
port := 8081
|
||||
const port uint16 = 8081
|
||||
|
||||
config.Init()
|
||||
|
||||
@ -25,19 +25,25 @@ func main() {
|
||||
database.InitDB()
|
||||
defer database.Close()
|
||||
|
||||
api.AddVideoHandlers()
|
||||
api.AddSettingsHandlers()
|
||||
api.AddTagHandlers()
|
||||
api.AddActorsHandlers()
|
||||
api.AddTvshowHandlers()
|
||||
api.AddHandlers()
|
||||
|
||||
videoparser.SetupSettingsWebsocket()
|
||||
|
||||
// add the static files
|
||||
static.ServeStaticFiles()
|
||||
|
||||
api2.ServerInit()
|
||||
// init api
|
||||
errc := make(chan error, 1)
|
||||
go func() {
|
||||
errc <- api2.ServerInit(port)
|
||||
}()
|
||||
|
||||
fmt.Printf("OpenMediacenter server up and running on port %d\n", port)
|
||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), nil))
|
||||
sigs := make(chan os.Signal, 1)
|
||||
signal.Notify(sigs, os.Interrupt)
|
||||
select {
|
||||
case err := <-errc:
|
||||
fmt.Printf("failed to serve: %v\n", err)
|
||||
case sig := <-sigs:
|
||||
fmt.Printf("terminating server: %v\n", sig)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user