()
| 15 | var schemaHandler http.Handler |
| 16 | |
| 17 | func GetSchemaHandler() http.Handler { |
| 18 | schemaStaticPath := filepath.Join(wavebase.GetWaveAppPath(), "schema") |
| 19 | stat, err := os.Stat(schemaStaticPath) |
| 20 | if schemaHandler == nil { |
| 21 | log.Println("Schema is nil, initializing") |
| 22 | if err == nil && stat.IsDir() { |
| 23 | log.Printf("Found static site at %s, serving\n", schemaStaticPath) |
| 24 | schemaHandler = http.FileServer(JsonDir{http.Dir(schemaStaticPath)}) |
| 25 | } else { |
| 26 | log.Printf("Did not find static site at %s, serving not found handler. stat: %v, err: %v\n", schemaStaticPath, stat, err) |
| 27 | schemaHandler = http.NotFoundHandler() |
| 28 | } |
| 29 | } |
| 30 | return addHeaders(schemaHandler) |
| 31 | } |
| 32 | |
| 33 | func addHeaders(next http.Handler) http.Handler { |
| 34 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
no test coverage detected