MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / GetSchemaHandler

Function GetSchemaHandler

pkg/schema/schema.go:17–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15var schemaHandler http.Handler
16
17func 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
33func addHeaders(next http.Handler) http.Handler {
34 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

Callers 1

RunWebServerFunction · 0.92

Calls 4

GetWaveAppPathFunction · 0.92
addHeadersFunction · 0.85
StatMethod · 0.80
IsDirMethod · 0.45

Tested by

no test coverage detected