You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
487 B

  1. package Webserver
  2. import (
  3. "log"
  4. "net/http"
  5. "PersonalWebsite/Database"
  6. "github.com/gorilla/mux"
  7. )
  8. func ViewPost(w http.ResponseWriter, r *http.Request) {
  9. var (
  10. urlParams map[string]string
  11. post Database.Post
  12. e error
  13. )
  14. urlParams = mux.Vars(r)
  15. post, e = Database.GetPostById(urlParams["id"])
  16. if e != nil {
  17. // TODO: Forward 404
  18. log.Println("Could not get user")
  19. http.Error(w, "Error", http.StatusInternalServerError)
  20. return
  21. }
  22. log.Println(post)
  23. }