diff --git a/README.md b/README.md new file mode 100644 index 0000000..fe9a17e --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# Media Proxy + +Proxy server to transform media files (images and PDFs) present in S3 bucket. + diff --git a/internal/mediaprocessor/media_processor.go b/internal/mediaprocessor/media_processor.go index 2f8a481..6c85990 100644 --- a/internal/mediaprocessor/media_processor.go +++ b/internal/mediaprocessor/media_processor.go @@ -53,7 +53,7 @@ func NewMediaProcessor() *MediaProcessor { func getContentType(imageBytes []byte) string { contentType := http.DetectContentType(imageBytes) - fmt.Println(contentType) + // fmt.Println(contentType) if contentType == "text/xml; charset=utf-8" { contentType = "image/svg+xml" } diff --git a/internal/server/server.go b/internal/server/server.go index a99d8ec..c88c6ec 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -105,6 +105,7 @@ func NewServer(config ServerConfig, mediaProcessor *mediaprocessor.MediaProcesso mux.Use(s.prometheusMiddleware) mux.HandleFunc("/{signature}/metadata/*", s.handleMetadataRequest) mux.HandleFunc("/{signature}/media/*", s.handleTransformRequest) + mux.HandleFunc("/health", s.health) return s } @@ -118,6 +119,10 @@ func (w *statusWriter) WriteHeader(code int) { w.ResponseWriter.WriteHeader(code) } +func (s *server) health(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) +} + func (s *server) prometheusMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { activeRequests.Inc()