Changed ExtendedApp to use ServeMux directly

More work on portfolio stuff
Added technologies to portfolio projects
This commit is contained in:
Caleb Gardner
2024-07-27 02:38:31 -05:00
parent f59a4207c4
commit cb53b7b831
7 changed files with 48 additions and 27 deletions
+16 -8
View File
@@ -2,19 +2,22 @@ package blog
import (
"context"
"encoding/json"
"net/http"
"github.com/CalebQ42/darkstorm-server/internal/backend"
"go.mongodb.org/mongo-driver/bson"
)
type PortfolioProject struct {
Title string `bson:"_id"`
Repository string `bson:"repository"`
Description string `bson:"description"`
Languages []struct {
Language string `bson:"language"`
Dates string `bson:"dates"`
} `bson:"language"`
Title string `json:"_id" bson:"_id"`
Repository string `json:"repository" bson:"repository"`
Description string `json:"description" bson:"description"`
Technologies []string `json:"technologies" bson:"technologies"`
Languages []struct {
Language string `json:"language" bson:"language"`
Dates string `json:"dates" bson:"dates"`
} `json:"language" bson:"language"`
}
func (b *BlogApp) Projects(languageFilter string) ([]PortfolioProject, error) {
@@ -32,5 +35,10 @@ func (b *BlogApp) Projects(languageFilter string) ([]PortfolioProject, error) {
}
func (b *BlogApp) reqPortfolio(w http.ResponseWriter, r *http.Request) {
//TODO
folio, err := b.Projects(r.URL.Query().Get("lang"))
if err != nil {
backend.ReturnError(w, http.StatusInternalServerError, "internal", "Server Error")
return
}
json.NewEncoder(w).Encode(folio)
}