Working on blog stuff

This commit is contained in:
Caleb Gardner
2024-06-17 07:28:33 -05:00
parent 7b15aab7ec
commit fdd8d49055
8 changed files with 388 additions and 7 deletions
+27
View File
@@ -0,0 +1,27 @@
package blog
import (
"net/http"
"github.com/CalebQ42/darkstorm-server/internal/backend"
"go.mongodb.org/mongo-driver/mongo"
)
type BlogApp struct {
back *backend.Backend
blogCol *mongo.Collection
authCol *mongo.Collection
}
func NewBlogApp(b *backend.Backend, db *mongo.Database, mux *http.ServeMux) *BlogApp {
out := &BlogApp{
back: b,
blogCol: db.Collection("blog"),
authCol: db.Collection("author"),
}
// setup mux
mux.HandleFunc("GET /blog/", out.LatestBlogs)
mux.HandleFunc("GET /blog/{blogID}", out.Blog)
//TODO
return out
}