File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- # SVG Analyzer [ <img alt =" Logo for SVGan " src =" cmd/server /static/favicon.svg" height =" 96 " align =" right " />] ( https://svgan.fileformat.info/ )
1+ # SVG Analyzer [ <img alt =" Logo for SVGan " src =" ui /static/favicon.svg" height =" 96 " align =" right " />] ( https://svgan.fileformat.info/ )
22
33[ ![ deploy] ( https://github.com/FileFormatInfo/svgan/actions/workflows/gcr-deploy.yaml/badge.svg )] ( https://github.com/FileFormatInfo/svgan/actions/workflows/gcr-deploy.yaml )
44
Original file line number Diff line number Diff line change 44 "net/http"
55 "os"
66 "strconv"
7+
8+ "github.com/FileFormatInfo/svgan/ui"
79)
810
911func main () {
@@ -15,11 +17,11 @@ func main() {
1517 var listenAddress = os .Getenv ("ADDRESS" )
1618
1719 http .HandleFunc ("/status.json" , statusHandler )
18- http .HandleFunc ("/robots.txt" , staticHandler .ServeHTTP )
19- http .HandleFunc ("/favicon.ico" , staticHandler .ServeHTTP )
20- http .HandleFunc ("/favicon.svg" , staticHandler .ServeHTTP )
21- http .HandleFunc ("/images/" , staticHandler .ServeHTTP )
22- http .HandleFunc ("GET /{$}" , staticHandler .ServeHTTP )
20+ http .HandleFunc ("/robots.txt" , ui . StaticHandler .ServeHTTP )
21+ http .HandleFunc ("/favicon.ico" , ui . StaticHandler .ServeHTTP )
22+ http .HandleFunc ("/favicon.svg" , ui . StaticHandler .ServeHTTP )
23+ http .HandleFunc ("/images/" , ui . StaticHandler .ServeHTTP )
24+ http .HandleFunc ("GET /{$}" , ui . StaticHandler .ServeHTTP )
2325 http .HandleFunc ("POST /{$}" , uploadHandler )
2426
2527 err := http .ListenAndServe (listenAddress + ":" + strconv .Itoa (listenPort ), nil )
Original file line number Diff line number Diff line change 1- package main
1+ package ui
22
33import (
44 "embed"
@@ -8,15 +8,22 @@ import (
88
99//go:embed static
1010var embeddedFiles embed.FS
11- var staticHandler = initStaticHandler ()
11+ var StaticHandler http. Handler
1212
13- func initStaticHandler () http.Handler {
13+ func initStaticHandler () ( http.Handler , error ) {
1414
1515 fsys , err := fs .Sub (embeddedFiles , "static" )
1616 if err != nil {
17- logger .Error ("unable to create static file system" , "error" , err )
18- panic (err )
17+ return nil , err
1918 }
2019
21- return http .FileServer (http .FS (fsys ))
20+ return http .FileServer (http .FS (fsys )), nil
21+ }
22+
23+ func init () {
24+ var err error
25+ StaticHandler , err = initStaticHandler ()
26+ if err != nil {
27+ panic (err )
28+ }
2229}
You can’t perform that action at this time.
0 commit comments