Added api endpoints and tests
This commit is contained in:
@@ -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
1
server/landingpage.go
Normal file
@@ -0,0 +1 @@
|
||||
package server
|
||||
Reference in New Issue
Block a user