1
0

A little refactoring in main.go.

This commit is contained in:
Alexander Andreev 2023-07-22 23:17:45 +04:00
parent 4cc4d0138a
commit 832387f663
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -2,14 +2,14 @@ package main
import (
"dwelling-radio/internal/configuration"
"dwelling-radio/internal/http"
ihttp "dwelling-radio/internal/http"
"dwelling-radio/internal/radio"
"dwelling-radio/web"
"flag"
"fmt"
"io/fs"
"log"
nethttp "net/http"
"net/http"
"os"
"os/signal"
"syscall"
@ -51,24 +51,24 @@ func main() {
}
defer playlistWatcher.Close()
hand := http.NewHandlers(config)
hand := ihttp.NewHandlers(config)
r := httpr.New()
r.Handler(nethttp.MethodGet, "/", hand.Index)
r.Handler(http.MethodGet, "/", hand.Index)
r.Handler(nethttp.MethodGet, "/status", hand.Status)
r.Handler(nethttp.MethodGet, "/lastsong", hand.LastSong)
r.Handler(http.MethodGet, "/status", hand.Status)
r.Handler(http.MethodGet, "/lastsong", hand.LastSong)
r.Handler(nethttp.MethodGet, "/playlist", hand.Playlist)
r.Handler(nethttp.MethodGet, "/filelist", hand.Filelist)
r.Handler(http.MethodGet, "/playlist", hand.Playlist)
r.Handler(http.MethodGet, "/filelist", hand.Filelist)
r.Handler(nethttp.MethodGet, "/robots.txt", http.RobotsTxt)
r.Handler(nethttp.MethodGet, "/sitemap.xml", http.SitemapXML)
r.Handler(nethttp.MethodGet, "/favicon.svg", http.Favicon)
r.Handler(http.MethodGet, "/robots.txt", ihttp.RobotsTxt)
r.Handler(http.MethodGet, "/sitemap.xml", ihttp.SitemapXML)
r.Handler(http.MethodGet, "/favicon.svg", ihttp.Favicon)
r.ServeStatic("/assets/*filepath", web.Assets())
srv := http.NewHttpServer(r)
srv := ihttp.NewHttpServer(r)
if err := srv.Start(config.SplitNetworkAddress()); err != nil {
log.Fatalln(err)