package Configuration // Imports import ( "errors" "net/url" "os" ) // Validate File Server func validateFileServer(fileServerConfiguration FileServerConfiguration) error { // If Active if fileServerConfiguration.Active == true { // Route Number var routeNumber uint // Routes for routeNumber = 0; routeNumber < uint(len(fileServerConfiguration.Routes)); routeNumber++ { // Resource Path item, err := os.Stat(fileServerConfiguration.Routes[routeNumber].ResourcePath) // Handle Error if err != nil { return errors.New("Error With Resource Path") } // Resource Path if item.IsDir() == false { return errors.New("Error With Resrouce Path") } // Serve Path if string(fileServerConfiguration.Routes[routeNumber].ServePath[0]) != "/" { return errors.New("Error With Serve Path") } // Serve Path _, err = url.ParseRequestURI(fileServerConfiguration.Routes[routeNumber].ServePath) // Handle Error if err != nil { return errors.New("Error With Serve Path") } } } // Return return nil }