diff --git a/filesystem.go b/filesystem.go index 0b5b27220..5664f0987 100644 --- a/filesystem.go +++ b/filesystem.go @@ -19,24 +19,24 @@ import ( "net/http" ) -// Ensure nopStaticFileSystem implements interface. -var _ StaticFileSystem = &nopStaticFileSystem{} +// Ensure nopFileSystem implements interface. +var _ FileSystem = &nopFileSystem{} -// StaticFileSystem represents an interface for a static WebUI. -type StaticFileSystem interface { +// FileSystem represents an interface for a WebUI file system. +type FileSystem interface { New() (http.FileSystem, error) } func init() { - NopStaticFileSystem = &nopStaticFileSystem{} + NopFileSystem = &nopFileSystem{} } -// NopStaticFileSystem represents a StaticFileSystem that returns an error if called. -var NopStaticFileSystem StaticFileSystem +// NopFileSystem represents a FileSystem that returns an error if called. +var NopFileSystem FileSystem -type nopStaticFileSystem struct{} +type nopFileSystem struct{} -// New is a no-op implementation of StaticFileSystem New method. -func (n *nopStaticFileSystem) New() (http.FileSystem, error) { - return nil, fmt.Errorf("static file system not implemented") +// New is a no-op implementation of FileSystem New method. +func (n *nopFileSystem) New() (http.FileSystem, error) { + return nil, fmt.Errorf("file system not implemented") } diff --git a/handler.go b/handler.go index 1688cf5a3..067219c8f 100644 --- a/handler.go +++ b/handler.go @@ -56,7 +56,7 @@ type Handler struct { BroadcastHandler BroadcastHandler StatusHandler StatusHandler - StaticFileSystem StaticFileSystem + FileSystem FileSystem // Local hostname & cluster configuration. Node *Node @@ -102,7 +102,7 @@ func NewHandler() *Handler { Broadcaster: NopBroadcaster, //BroadcastHandler: NopBroadcastHandler, // TODO: implement the nop //StatusHandler: NopStatusHandler, // TODO: implement the nop - StaticFileSystem: NopStaticFileSystem, + FileSystem: NopFileSystem, LogOutput: os.Stderr, } @@ -291,7 +291,7 @@ func (h *Handler) handleWebUI(w http.ResponseWriter, r *http.Request) { http.Error(w, "Welcome. Pilosa is running. Visit https://www.pilosa.com/docs/ for more information or try the WebUI by visiting this URL in your browser.", http.StatusNotFound) return } - statikFS, err := h.StaticFileSystem.New() + statikFS, err := h.FileSystem.New() if err != nil { h.writeQueryResponse(w, r, &QueryResponse{Err: err}) h.logger().Println("Pilosa WebUI is not available. Please run `make generate-statik` before building Pilosa with `make install`.") diff --git a/handler_test.go b/handler_test.go index 6386f53f9..4f3f12f77 100644 --- a/handler_test.go +++ b/handler_test.go @@ -29,9 +29,9 @@ import ( "github.com/gogo/protobuf/proto" "github.com/pilosa/pilosa" - "github.com/pilosa/pilosa/filesystem" "github.com/pilosa/pilosa/internal" "github.com/pilosa/pilosa/pql" + "github.com/pilosa/pilosa/statikfs" "github.com/pilosa/pilosa/test" ) @@ -1854,7 +1854,7 @@ func TestHandler_WebUI(t *testing.T) { h := test.NewHandler() h.Holder = hldr.Holder h.Cluster = test.NewCluster(1) - h.StaticFileSystem = &filesystem.StatikFS{} + h.FileSystem = &statikfs.FileSystem{} w := httptest.NewRecorder() h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/", nil)) diff --git a/server/server.go b/server/server.go index e056bc76d..52df0e52e 100644 --- a/server/server.go +++ b/server/server.go @@ -33,9 +33,9 @@ import ( "crypto/tls" "github.com/pilosa/pilosa" - "github.com/pilosa/pilosa/filesystem" "github.com/pilosa/pilosa/gcnotify" "github.com/pilosa/pilosa/gossip" + "github.com/pilosa/pilosa/statikfs" "github.com/pilosa/pilosa/statsd" ) @@ -193,7 +193,7 @@ func (m *Command) SetupServer() error { m.Server.Cluster.RemoteClient = c // Statik file system. - m.Server.Handler.StaticFileSystem = &filesystem.StatikFS{} + m.Server.Handler.FileSystem = &statikfs.FileSystem{} // Default coordintor to port 0 when not specified so that coordinator // can be set to the value of server.URI after server binds to a port. diff --git a/filesystem/statik.go b/statikfs/filesystem.go similarity index 70% rename from filesystem/statik.go rename to statikfs/filesystem.go index 405e31a11..306034a1f 100644 --- a/filesystem/statik.go +++ b/statikfs/filesystem.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package filesystem +package statikfs import ( "net/http" @@ -21,12 +21,13 @@ import ( "github.com/rakyll/statik/fs" ) -// Ensure nopStaticFileSystem implements interface. -var _ pilosa.StaticFileSystem = &StatikFS{} +// Ensure nopFileSystem implements interface. +var _ pilosa.FileSystem = &FileSystem{} -type StatikFS struct{} +// FileSystem represents a static FileSystem. +type FileSystem struct{} -// New is a statik implementation of StaticFileSystem New method. -func (s *StatikFS) New() (http.FileSystem, error) { +// New is a statik implementation of FileSystem New method. +func (s *FileSystem) New() (http.FileSystem, error) { return fs.New() }