Browse Source

Adds some logging info output

pull/8/head^2
Noah Pederson 3 years ago
parent
commit
d30ffd695f
  1. 6
      pkg/mediaservice/web/web.go
  2. 4
      pkg/textservice/web/web.go

6
pkg/mediaservice/web/web.go

@ -107,7 +107,9 @@ func bindGetMediaHandler(r chi.Router, s bakamoews.MediaService) {
http.Error(w, string(errorResponseText), http.StatusBadRequest)
return
}
log.Printf("Searching for media with ID %d", mediaID)
media, err := s.GetMedia(uint64(mediaID))
if err != nil {
log.Printf("Unable to retrieve media: %s", err)
errorOutput := bakamoews.ErrorResponse{
@ -118,6 +120,7 @@ func bindGetMediaHandler(r chi.Router, s bakamoews.MediaService) {
http.Error(w, string(errorResponseText), http.StatusInternalServerError)
return
}
log.Printf("Found media!")
responseText, err := json.Marshal(media)
if err != nil {
errorOutput := bakamoews.ErrorResponse{
@ -280,6 +283,7 @@ func bindGetMediaGroupHandler(r chi.Router, s bakamoews.MediaService) {
http.Error(w, string(errorResponseText), http.StatusBadRequest)
return
}
log.Printf("Searching for mediagroup with ID: %d", mediaGroupID)
mediaGroup, err := s.GetMediaGroup(uint64(mediaGroupID))
if err != nil {
log.Printf("Unable to retrieve media group: %s", err)
@ -291,7 +295,7 @@ func bindGetMediaGroupHandler(r chi.Router, s bakamoews.MediaService) {
http.Error(w, string(errorResponseText), http.StatusInternalServerError)
return
}
log.Printf("Found mediagroup!")
childrenMediaGroups, err := s.GetChildrenMediaGroup(mediaGroup.ID)
if err != nil {
log.Printf("Unable to retrieve children media groups for media group with ID: %d", mediaGroup.ID)

4
pkg/textservice/web/web.go

@ -76,6 +76,7 @@ func bindCreateTextHandler(r chi.Router, s bakamoews.TextService) {
func bindGetTextHandler(r chi.Router, s bakamoews.TextService) {
r.Get("/get/{id}", func(w http.ResponseWriter, r *http.Request) {
objectID := chi.URLParam(r, "id")
log.Printf("Searching for text object with name: %s", objectID)
objectReader, err := s.Get(objectID)
if err != nil {
@ -88,6 +89,7 @@ func bindGetTextHandler(r chi.Router, s bakamoews.TextService) {
http.Error(w, string(errorResponseText), http.StatusInternalServerError)
return
}
log.Printf("Found text object. Streaming back to browser...")
defer objectReader.Close()
w.Header().Set("Content-Type", "application/text")
w.WriteHeader(http.StatusOK)
@ -101,6 +103,7 @@ func bindConvertTextHandler(r chi.Router, s bakamoews.TextService) {
r.Get("/get/{id}/{format}", func(w http.ResponseWriter, r *http.Request) {
objectID := chi.URLParam(r, "id")
format := chi.URLParam(r, "format")
log.Printf("Converting media with name %s to format %s", objectID, format)
fileReader, err := s.Convert(objectID, format)
if err != nil {
log.Printf("Unable to convert text: %s", err)
@ -112,6 +115,7 @@ func bindConvertTextHandler(r chi.Router, s bakamoews.TextService) {
http.Error(w, string(errorResponseText), http.StatusInternalServerError)
return
}
log.Printf("Success! Streaming to browser...")
defer fileReader.Close()
contentDisposition := fmt.Sprintf("attachment; filename='%s.%s'", objectID, format)

Loading…
Cancel
Save