Merge pull request #2134 from influxdata/fix/issue-2050
fix(http): Fix developer mode defaultpull/10616/head
commit
d9e91b2602
|
@ -40,7 +40,7 @@ import (
|
||||||
_ "github.com/influxdata/platform/tsdb/tsi1"
|
_ "github.com/influxdata/platform/tsdb/tsi1"
|
||||||
_ "github.com/influxdata/platform/tsdb/tsm1"
|
_ "github.com/influxdata/platform/tsdb/tsm1"
|
||||||
pzap "github.com/influxdata/platform/zap"
|
pzap "github.com/influxdata/platform/zap"
|
||||||
"github.com/opentracing/opentracing-go"
|
opentracing "github.com/opentracing/opentracing-go"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
|
@ -367,6 +367,7 @@ func (m *Main) run(ctx context.Context) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
handlerConfig := &http.APIBackend{
|
handlerConfig := &http.APIBackend{
|
||||||
|
DeveloperMode: m.developerMode,
|
||||||
Logger: m.logger,
|
Logger: m.logger,
|
||||||
NewBucketService: source.NewBucketService,
|
NewBucketService: source.NewBucketService,
|
||||||
NewQueryService: source.NewQueryService,
|
NewQueryService: source.NewQueryService,
|
||||||
|
|
|
@ -34,6 +34,7 @@ type APIHandler struct {
|
||||||
// APIBackend is all services and associated parameters required to construct
|
// APIBackend is all services and associated parameters required to construct
|
||||||
// an APIHandler.
|
// an APIHandler.
|
||||||
type APIBackend struct {
|
type APIBackend struct {
|
||||||
|
DeveloperMode bool
|
||||||
Logger *zap.Logger
|
Logger *zap.Logger
|
||||||
|
|
||||||
NewBucketService func(*platform.Source) (platform.BucketService, error)
|
NewBucketService func(*platform.Source) (platform.BucketService, error)
|
||||||
|
|
|
@ -10,9 +10,9 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Dir is prefix of the assets in the bindata
|
// 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 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 is the prefix of the assets in development mode
|
||||||
DebugDir = "ui/build"
|
DebugDir = "ui/build"
|
||||||
// DebugDefault is the default item to load if 404
|
// DebugDefault is the default item to load if 404
|
||||||
|
@ -23,20 +23,20 @@ const (
|
||||||
|
|
||||||
// AssetHandler is an http handler for serving chronograf assets.
|
// AssetHandler is an http handler for serving chronograf assets.
|
||||||
type AssetHandler struct {
|
type AssetHandler struct {
|
||||||
Develop bool
|
DeveloperMode bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewAssetHandler is the constructor an asset handler.
|
// NewAssetHandler is the constructor an asset handler.
|
||||||
func NewAssetHandler() *AssetHandler {
|
func NewAssetHandler() *AssetHandler {
|
||||||
return &AssetHandler{
|
return &AssetHandler{
|
||||||
Develop: true,
|
DeveloperMode: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServeHTTP implements the http handler interface for serving assets.
|
// ServeHTTP implements the http handler interface for serving assets.
|
||||||
func (h *AssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h *AssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
var assets chronograf.Assets
|
var assets chronograf.Assets
|
||||||
if h.Develop {
|
if h.DeveloperMode {
|
||||||
assets = &dist.DebugAssets{
|
assets = &dist.DebugAssets{
|
||||||
Dir: DebugDir,
|
Dir: DebugDir,
|
||||||
Default: DebugDefault,
|
Default: DebugDefault,
|
||||||
|
|
|
@ -34,8 +34,11 @@ func NewPlatformHandler(b *APIBackend) *PlatformHandler {
|
||||||
h.RegisterNoAuthRoute("POST", "/api/v2/setup")
|
h.RegisterNoAuthRoute("POST", "/api/v2/setup")
|
||||||
h.RegisterNoAuthRoute("GET", "/api/v2/setup")
|
h.RegisterNoAuthRoute("GET", "/api/v2/setup")
|
||||||
|
|
||||||
|
assetHandler := NewAssetHandler()
|
||||||
|
assetHandler.DeveloperMode = b.DeveloperMode
|
||||||
|
|
||||||
return &PlatformHandler{
|
return &PlatformHandler{
|
||||||
AssetHandler: NewAssetHandler(),
|
AssetHandler: assetHandler,
|
||||||
APIHandler: h,
|
APIHandler: h,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,10 +33,10 @@ type FindOptions struct {
|
||||||
// QueryParams returns a map containing url query params.
|
// QueryParams returns a map containing url query params.
|
||||||
func (f FindOptions) QueryParams() map[string][]string {
|
func (f FindOptions) QueryParams() map[string][]string {
|
||||||
qp := map[string][]string{
|
qp := map[string][]string{
|
||||||
"limit": []string{strconv.Itoa(f.Limit)},
|
"limit": {strconv.Itoa(f.Limit)},
|
||||||
"offset": []string{strconv.Itoa(f.Offset)},
|
"offset": {strconv.Itoa(f.Offset)},
|
||||||
"sortBy": []string{f.SortBy},
|
"sortBy": {f.SortBy},
|
||||||
"descending": []string{strconv.FormatBool(f.Descending)},
|
"descending": {strconv.FormatBool(f.Descending)},
|
||||||
}
|
}
|
||||||
|
|
||||||
return qp
|
return qp
|
||||||
|
|
Loading…
Reference in New Issue