diff --git a/db/migrate.go b/db/migrate.go index 1def43a..fecef46 100644 --- a/db/migrate.go +++ b/db/migrate.go @@ -2,7 +2,7 @@ package db import ( "database/sql" - "log" + "log/slog" "os" ) @@ -19,6 +19,6 @@ func Migrate(db *sql.DB, migrations []string) { res, err := db.Exec(string(data)) _ = res CheckError(err) - log.Print("Applied migration " + x) + slog.Info("Applied migration", "name", x) } } diff --git a/handlers/post.go b/handlers/post.go new file mode 100644 index 0000000..c5b5a23 --- /dev/null +++ b/handlers/post.go @@ -0,0 +1,10 @@ +package handlers + +import ( + "log" + "net/http" +) + +func PostHandler(w http.ResponseWriter, req *http.Request) { + log.Print(req.URL.Path) +} \ No newline at end of file diff --git a/handlers/postpage.go b/handlers/postpage.go new file mode 100644 index 0000000..bb2d664 --- /dev/null +++ b/handlers/postpage.go @@ -0,0 +1,11 @@ +package handlers + +import ( + "log" + "net/http" +) + +func PostPage(w http.ResponseWriter, req *http.Request) { + log.Printf("Serving a post") + log.Print(req.URL.Path) +} \ No newline at end of file diff --git a/handlers/public.go b/handlers/public.go new file mode 100644 index 0000000..2abe22b --- /dev/null +++ b/handlers/public.go @@ -0,0 +1,10 @@ +package handlers + +import ( + "log" + "net/http" +) + +func Public(w http.ResponseWriter, req *http.Request) { + log.Print(req.URL.Path) +} \ No newline at end of file diff --git a/handlers/user.go b/handlers/user.go new file mode 100644 index 0000000..72ad445 --- /dev/null +++ b/handlers/user.go @@ -0,0 +1,10 @@ +package handlers + +import ( + "log" + "net/http" +) + +func UserHandler(w http.ResponseWriter, req *http.Request) { + log.Print(req.Method) +} \ No newline at end of file diff --git a/main.go b/main.go index 761d164..a485bbb 100644 --- a/main.go +++ b/main.go @@ -2,11 +2,12 @@ package main import ( "database/sql" - "fmt" + "net/http" + "log" _ "github.com/mattn/go-sqlite3" dbpkg "nkeller.dev/blog_software/db" - usrpkg "nkeller.dev/blog_software/user" + "nkeller.dev/blog_software/handlers" ) type Post struct { @@ -31,10 +32,12 @@ func main() { } dbpkg.Migrate(db, migrations[:]) - user, err := usrpkg.Create(db, "profilelag2", "Hello") - if err != nil { - panic(err) - } - fmt.Println(user) - fmt.Printf("user: %v\n", user) + http.HandleFunc("/user", handlers.UserHandler) + http.HandleFunc("/post", handlers.PostHandler) + + http.HandleFunc("/", handlers.Public) + http.HandleFunc("/post/", handlers.PostPage) + + log.Print("Starting Blog_Software at http://localhost:8080") + http.ListenAndServe(":8080", nil) } diff --git a/public/JetBrainsMono-Regular.woff2 b/public/JetBrainsMono-Regular.woff2 new file mode 100644 index 0000000..40da427 Binary files /dev/null and b/public/JetBrainsMono-Regular.woff2 differ diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..0b68506 --- /dev/null +++ b/public/index.html @@ -0,0 +1,31 @@ + + +
+ + +