Added api endpoints and tests

This commit is contained in:
2022-01-24 12:59:43 +01:00
parent 10b768743b
commit cfbdcc7f82
36 changed files with 1781 additions and 315 deletions

View File

@@ -14,8 +14,8 @@ func Article(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html")
articleName := mux.Vars(r)["article"]
article, err := database.GetDB().GetArticleByName(articleName)
if err != nil {
var article string
if err := database.GetDB().Table("article").Select("html").Where("name = ?", articleName).First(&article).Error; err != nil {
if err == sql.ErrNoRows {
Error404(w, r)
} else {
@@ -25,5 +25,5 @@ func Article(w http.ResponseWriter, r *http.Request) {
}
w.WriteHeader(http.StatusOK)
fmt.Fprint(w, article.Html)
fmt.Fprint(w, article)
}

1
server/landingpage.go Normal file
View File

@@ -0,0 +1 @@
package server