22package api
33
44import (
5- "encoding/base64"
65 "encoding/json"
76 "net/http"
87 "strconv"
@@ -206,26 +205,19 @@ func (h *LogsHandler) HandleGetAllLogs(w http.ResponseWriter, r *http.Request) {
206205 }
207206}
208207
209- // HandleGetLogo returns the logo as base64-encoded PNG
210- // GET /api /logo
208+ // HandleGetLogo returns the logo PNG file
209+ // GET /static /logo.png
211210func (h * LogsHandler ) HandleGetLogo (w http.ResponseWriter , r * http.Request ) {
212- if r .Method != http .MethodGet {
211+ if r .Method != http .MethodGet && r . Method != http . MethodHead {
213212 http .Error (w , "Method not allowed" , http .StatusMethodNotAllowed )
214213 return
215214 }
216215
217- logoBase64 := base64 .StdEncoding .EncodeToString (ui .LogoPNG )
218-
219- response := map [string ]interface {}{
220- "logo" : logoBase64 ,
221- "type" : "image/png" ,
222- }
223-
224- w .Header ().Set ("Content-Type" , "application/json" )
225- if err := json .NewEncoder (w ).Encode (response ); err != nil {
226- h .logger .Error ("failed to encode logo response" , err )
227- http .Error (w , "Internal server error" , http .StatusInternalServerError )
228- return
216+ w .Header ().Set ("Content-Type" , "image/png" )
217+ w .Header ().Set ("Cache-Control" , "public, max-age=3600" ) // Cache for 1 hour
218+ w .WriteHeader (http .StatusOK )
219+ if r .Method != http .MethodHead {
220+ w .Write (ui .LogoPNG )
229221 }
230222}
231223
@@ -268,7 +260,6 @@ func (h *LogsHandler) RegisterRoutes(mux *http.ServeMux) {
268260 mux .HandleFunc ("/api/logs/since" , h .HandleGetLogsSince )
269261 mux .HandleFunc ("/api/logs/stats" , h .HandleGetStats )
270262 mux .HandleFunc ("/api/logs/clear" , h .HandleClearLogs )
271- mux .HandleFunc ("/api/logo" , h .HandleGetLogo )
272263
273264 h .logger .Info ("log API routes registered" ,
274265 "endpoints" , []string {
@@ -277,7 +268,6 @@ func (h *LogsHandler) RegisterRoutes(mux *http.ServeMux) {
277268 "GET /api/logs/since" ,
278269 "GET /api/logs/stats" ,
279270 "DELETE /api/logs/clear" ,
280- "GET /api/logo" ,
281271 })
282272}
283273
@@ -290,7 +280,6 @@ func (h *LogsHandler) RegisterRoutesWithPrefix(mux *http.ServeMux, prefix string
290280 mux .HandleFunc (prefix + "/api/logs/since" , h .HandleGetLogsSince )
291281 mux .HandleFunc (prefix + "/api/logs/stats" , h .HandleGetStats )
292282 mux .HandleFunc (prefix + "/api/logs/clear" , h .HandleClearLogs )
293- mux .HandleFunc (prefix + "/api/logo" , h .HandleGetLogo )
294283
295284 h .logger .Info ("log API routes registered with prefix" ,
296285 "prefix" , prefix ,
@@ -300,7 +289,6 @@ func (h *LogsHandler) RegisterRoutesWithPrefix(mux *http.ServeMux, prefix string
300289 "GET " + prefix + "/api/logs/since" ,
301290 "GET " + prefix + "/api/logs/stats" ,
302291 "DELETE " + prefix + "/api/logs/clear" ,
303- "GET " + prefix + "/api/logo" ,
304292 })
305293}
306294
@@ -324,7 +312,7 @@ func (h *LogsHandler) RegisterInterimRoutes(mux *http.ServeMux, basePath string)
324312 mux .HandleFunc (basePath + "/api/logs/since" , h .HandleGetLogsSince )
325313 mux .HandleFunc (basePath + "/api/logs/stats" , h .HandleGetStats )
326314 mux .HandleFunc (basePath + "/api/logs/clear" , h .HandleClearLogs )
327- mux .HandleFunc (basePath + "/api /logo" , h .HandleGetLogo )
315+ mux .HandleFunc (basePath + "/static /logo.png " , h .HandleGetLogo )
328316 mux .HandleFunc (basePath + "/static/logs.css" , h .HandleGetCSS )
329317 mux .HandleFunc (basePath + "/static/logs.js" , h .HandleGetJS )
330318
@@ -336,7 +324,7 @@ func (h *LogsHandler) RegisterInterimRoutes(mux *http.ServeMux, basePath string)
336324 "GET " + basePath + "/api/logs/since" ,
337325 "GET " + basePath + "/api/logs/stats" ,
338326 "DELETE " + basePath + "/api/logs/clear" ,
339- "GET " + basePath + "/api /logo" ,
327+ "GET " + basePath + "/static /logo.png " ,
340328 "GET " + basePath + "/static/logs.css" ,
341329 "GET " + basePath + "/static/logs.js" ,
342330 })
@@ -358,9 +346,9 @@ func (h *LogsHandler) RegisterInterimRoutesWithAuth(mux *http.ServeMux, basePath
358346 mux .Handle (basePath + "/api/logs/since" , oauthMW .Wrap (http .HandlerFunc (h .HandleGetLogsSince )))
359347 mux .Handle (basePath + "/api/logs/stats" , oauthMW .Wrap (http .HandlerFunc (h .HandleGetStats )))
360348 mux .Handle (basePath + "/api/logs/clear" , oauthMW .Wrap (http .HandlerFunc (h .HandleClearLogs )))
361- mux .Handle (basePath + "/api/logo" , oauthMW .Wrap (http .HandlerFunc (h .HandleGetLogo )))
362349
363- // Static assets are not protected - they're just CSS/JS files
350+ // Static assets are not protected - they're just CSS/JS/image files
351+ mux .HandleFunc (basePath + "/static/logo.png" , h .HandleGetLogo )
364352 mux .HandleFunc (basePath + "/static/logs.css" , h .HandleGetCSS )
365353 mux .HandleFunc (basePath + "/static/logs.js" , h .HandleGetJS )
366354
@@ -372,7 +360,7 @@ func (h *LogsHandler) RegisterInterimRoutesWithAuth(mux *http.ServeMux, basePath
372360 "GET " + basePath + "/api/logs/since" ,
373361 "GET " + basePath + "/api/logs/stats" ,
374362 "DELETE " + basePath + "/api/logs/clear" ,
375- "GET " + basePath + "/api /logo" ,
363+ "GET " + basePath + "/static /logo.png " ,
376364 "GET " + basePath + "/static/logs.css" ,
377365 "GET " + basePath + "/static/logs.js" ,
378366 })
0 commit comments