Browse Source

Adds some logging info output

pull/8/head
Noah Pederson 2 years ago
parent
commit
73de8ab5d2
3 changed files with 62 additions and 1 deletions
  1. +53
    -0
      docker-compose.yml
  2. +5
    -1
      pkg/mediaservice/web/web.go
  3. +4
    -0
      pkg/textservice/web/web.go

+ 53
- 0
docker-compose.yml View File

@ -0,0 +1,53 @@
version: '3.5'
services:
nginx:
image: nginx
restart: always
expose:
- "80"
networks:
- web
volumes:
- "/opt/apps/nginx/www:/usr/share/nginx/html"
- "/opt/apps/nginx/koukaiws.conf:/etc/nginx/conf.d/default.conf"
labels:
- "traefik.frontend.rule=Host:dev01.koukai.xyz"
- "traefik.port=80"
- "traefik.backend=nginx"
- "traefik.docker.network=web"
depends_on:
- "koukaiws"
postgres:
image: postgres
restart: always
expose:
- "5432"
networks:
- web
volumes:
- "postgres_storage:/var/lib/postgresql/data"
env_file:
- /opt/apps/nginx/env
koukaiws:
image: registry.saten.host/chiefnoah/koukaiws:latest
restart: always
expose:
- "8080"
volumes:
- "/usr/bin/pandoc:/usr/bin/pandoc"
networks:
- web
env_file:
- /opt/apps/nginx/env
depends_on:
- "postgres"
volumes:
postgres_storage:
external: true
networks:
web:
external: true

+ 5
- 1
pkg/mediaservice/web/web.go View File

@ -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
- 0
pkg/textservice/web/web.go View File

@ -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