rename StaticFileSystem to FileSystem. re-org statik files

This commit is contained in:
Travis Turner 2018-03-07 11:12:05 -06:00
parent e03dee9386
commit d6896ea0a5
No known key found for this signature in database
GPG key ID: 7F08008DFD9314C9
5 changed files with 25 additions and 24 deletions

View file

@ -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")
}

View file

@ -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`.")

View file

@ -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))

View file

@ -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.

View file

@ -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()
}