move middleware and routes/ app into internal dir

This commit is contained in:
2025-01-11 19:10:18 +01:00
parent f083496ebc
commit 20edc0f2f9
6 changed files with 57 additions and 44 deletions

View File

@@ -1,6 +1,8 @@
package main
import (
"crowsnest/internal/app"
"crowsnest/internal/middleware"
"crowsnest/internal/model/database"
"log"
"net/http"
@@ -8,10 +10,6 @@ import (
_ "github.com/lib/pq"
)
type App struct {
articles *database.ArticleModel
}
func main() {
db, err := database.DbConnection()
if err != nil {
@@ -19,14 +17,12 @@ func main() {
}
// define app
app := &App{
articles: &database.ArticleModel{DB: db},
}
webapp := app.NewApp(db)
// start web server
server := http.Server{
Addr: ":8080",
Handler: app.routes(),
Handler: middleware.Logging(webapp.Routes()),
}
log.Println("server started, listening on :8080")