44 lines
827 B
Go
44 lines
827 B
Go
package main
|
|
|
|
import (
|
|
"database/sql"
|
|
"net/http"
|
|
"log"
|
|
|
|
_ "github.com/mattn/go-sqlite3"
|
|
dbpkg "nkeller.dev/blog_software/db"
|
|
"nkeller.dev/blog_software/handlers"
|
|
)
|
|
|
|
type Post struct {
|
|
id int
|
|
created_at int
|
|
creator_id int
|
|
title string
|
|
description string
|
|
content string
|
|
tags string
|
|
}
|
|
|
|
func main() {
|
|
// DB and Migrations
|
|
db, err := sql.Open("sqlite3", "./db/blogging.db")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer db.Close()
|
|
migrations := [...]string{
|
|
"1784776258",
|
|
}
|
|
dbpkg.Migrate(db, migrations[:])
|
|
|
|
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)
|
|
}
|