Merge pull request #2134 from influxdata/fix/issue-2050

fix(http): Fix developer mode default
pull/10616/head
ABond 2018-12-21 16:42:33 -05:00 committed by GitHub
commit d9e91b2602
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 12 deletions

View File

@ -40,7 +40,7 @@ import (
_ "github.com/influxdata/platform/tsdb/tsi1"
_ "github.com/influxdata/platform/tsdb/tsm1"
pzap "github.com/influxdata/platform/zap"
"github.com/opentracing/opentracing-go"
opentracing "github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
@ -367,6 +367,7 @@ func (m *Main) run(ctx context.Context) (err error) {
}
handlerConfig := &http.APIBackend{
DeveloperMode: m.developerMode,
Logger: m.logger,
NewBucketService: source.NewBucketService,
NewQueryService: source.NewQueryService,

View File

@ -34,7 +34,8 @@ type APIHandler struct {
// APIBackend is all services and associated parameters required to construct
// an APIHandler.
type APIBackend struct {
Logger *zap.Logger
DeveloperMode bool
Logger *zap.Logger
NewBucketService func(*platform.Source) (platform.BucketService, error)
NewQueryService func(*platform.Source) (query.ProxyQueryService, error)

View File

@ -10,9 +10,9 @@ import (
const (
// Dir is prefix of the assets in the bindata
Dir = "../ui/build"
Dir = "../../ui/build"
// Default is the default item to load if 404
Default = "../ui/build/index.html"
Default = "../../ui/build/index.html"
// DebugDir is the prefix of the assets in development mode
DebugDir = "ui/build"
// DebugDefault is the default item to load if 404
@ -23,20 +23,20 @@ const (
// AssetHandler is an http handler for serving chronograf assets.
type AssetHandler struct {
Develop bool
DeveloperMode bool
}
// NewAssetHandler is the constructor an asset handler.
func NewAssetHandler() *AssetHandler {
return &AssetHandler{
Develop: true,
DeveloperMode: true,
}
}
// ServeHTTP implements the http handler interface for serving assets.
func (h *AssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
var assets chronograf.Assets
if h.Develop {
if h.DeveloperMode {
assets = &dist.DebugAssets{
Dir: DebugDir,
Default: DebugDefault,

View File

@ -34,8 +34,11 @@ func NewPlatformHandler(b *APIBackend) *PlatformHandler {
h.RegisterNoAuthRoute("POST", "/api/v2/setup")
h.RegisterNoAuthRoute("GET", "/api/v2/setup")
assetHandler := NewAssetHandler()
assetHandler.DeveloperMode = b.DeveloperMode
return &PlatformHandler{
AssetHandler: NewAssetHandler(),
AssetHandler: assetHandler,
APIHandler: h,
}
}

View File

@ -33,10 +33,10 @@ type FindOptions struct {
// QueryParams returns a map containing url query params.
func (f FindOptions) QueryParams() map[string][]string {
qp := map[string][]string{
"limit": []string{strconv.Itoa(f.Limit)},
"offset": []string{strconv.Itoa(f.Offset)},
"sortBy": []string{f.SortBy},
"descending": []string{strconv.FormatBool(f.Descending)},
"limit": {strconv.Itoa(f.Limit)},
"offset": {strconv.Itoa(f.Offset)},
"sortBy": {f.SortBy},
"descending": {strconv.FormatBool(f.Descending)},
}
return qp