Merge pull request #674 from influxdata/go-fix-content-type
Fix Content-Type of the index.html page to be text/htmlpull/10616/head
commit
ba9372ab3b
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -1,17 +1,25 @@
|
||||||
## v1.1.0 [unreleased]
|
## v1.1.0 [unreleased]
|
||||||
|
|
||||||
|
## v1.1.0-beta2 []
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
1. [#664](https://github.com/influxdata/chronograf/issues/664): Fix Content-Type of single-page app to always be text/html
|
||||||
|
1. [#671](https://github.com/influxdata/chronograf/issues/671): Fix multiple influxdb source freezing page
|
||||||
|
|
||||||
## v1.1.0-beta1 [2016-12-06]
|
## v1.1.0-beta1 [2016-12-06]
|
||||||
- Layouts
|
### Layouts
|
||||||
1. [#575](https://github.com/influxdata/chronograf/issues/556): Varnish Layout
|
1. [#575](https://github.com/influxdata/chronograf/issues/556): Varnish Layout
|
||||||
2. [#535](https://github.com/influxdata/chronograf/issues/535): Elasticsearch Layout
|
2. [#535](https://github.com/influxdata/chronograf/issues/535): Elasticsearch Layout
|
||||||
- Features
|
|
||||||
|
### Features
|
||||||
1. [#565](https://github.com/influxdata/chronograf/issues/565) [#246](https://github.com/influxdata/chronograf/issues/246) [#234](https://github.com/influxdata/chronograf/issues/234) [#311](https://github.com/influxdata/chronograf/issues/311) Github Oauth login
|
1. [#565](https://github.com/influxdata/chronograf/issues/565) [#246](https://github.com/influxdata/chronograf/issues/246) [#234](https://github.com/influxdata/chronograf/issues/234) [#311](https://github.com/influxdata/chronograf/issues/311) Github Oauth login
|
||||||
2. [#487](https://github.com/influxdata/chronograf/issues/487): Warn users if they are using a kapacitor instance that is configured to use an influxdb instance that does not match the current source
|
2. [#487](https://github.com/influxdata/chronograf/issues/487): Warn users if they are using a kapacitor instance that is configured to use an influxdb instance that does not match the current source
|
||||||
3. [#597](https://github.com/influxdata/chronograf/issues/597): Filter host by series tags
|
3. [#597](https://github.com/influxdata/chronograf/issues/597): Filter host by series tags
|
||||||
4. [#568](https://github.com/influxdata/chronograf/issues/568): [#569](https://github.com/influxdata/chronograf/issues/569): Add support for multiple y-axis, labels, and ranges
|
4. [#568](https://github.com/influxdata/chronograf/issues/568): [#569](https://github.com/influxdata/chronograf/issues/569): Add support for multiple y-axis, labels, and ranges
|
||||||
5. [#605](https://github.com/influxdata/chronograf/issues/605): Number visualization type in host view
|
5. [#605](https://github.com/influxdata/chronograf/issues/605): Number visualization type in host view
|
||||||
5. [#607](https://github.com/influxdata/chronograf/issues/607): Number and line graph visualization type in host view
|
5. [#607](https://github.com/influxdata/chronograf/issues/607): Number and line graph visualization type in host view
|
||||||
- Bug Fixes
|
|
||||||
|
### Bug Fixes
|
||||||
1. [#536](https://github.com/influxdata/chronograf/issues/536) Redirect the user to the kapacitor config screen if they are attempting to view or edit alerts without a configured kapacitor
|
1. [#536](https://github.com/influxdata/chronograf/issues/536) Redirect the user to the kapacitor config screen if they are attempting to view or edit alerts without a configured kapacitor
|
||||||
2. [#539](https://github.com/influxdata/chronograf/issues/539) Zoom works only on the first graph of a layout
|
2. [#539](https://github.com/influxdata/chronograf/issues/539) Zoom works only on the first graph of a layout
|
||||||
3. [#494](https://github.com/influxdata/chronograf/issues/494) Layouts should only be displayed when the measurement is present
|
3. [#494](https://github.com/influxdata/chronograf/issues/494) Layouts should only be displayed when the measurement is present
|
||||||
|
|
|
@ -19,14 +19,24 @@ func (d *DebugAssets) Handler() http.Handler {
|
||||||
return http.FileServer(NewDir(d.Dir, d.Default))
|
return http.FileServer(NewDir(d.Dir, d.Default))
|
||||||
}
|
}
|
||||||
|
|
||||||
// BindataAssets serves assets from go-bindata
|
// BindataAssets serves assets from go-bindata, but, also serves Default if assent doesn't exist
|
||||||
|
// This is to support single-page react-apps with its own router.
|
||||||
type BindataAssets struct {
|
type BindataAssets struct {
|
||||||
Prefix string // Prefix is prepended to the http file request
|
Prefix string // Prefix is prepended to the http file request
|
||||||
Default string // Default is the file to serve if the file is not found
|
Default string // Default is the file to serve if the file is not found
|
||||||
|
DefaultContentType string // DefaultContentType is the content type of the default file
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handler serves go-bindata using a go-bindata-assetfs façade
|
// Handler serves go-bindata using a go-bindata-assetfs façade
|
||||||
func (b *BindataAssets) Handler() http.Handler {
|
func (b *BindataAssets) Handler() http.Handler {
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServeHTTP wraps http.FileServer by returning a default asset if the asset
|
||||||
|
// doesn't exist. This supports single-page react-apps with its own
|
||||||
|
// built-in router. Additionally, we override the content-type if the
|
||||||
|
// Default file is used.
|
||||||
|
func (b *BindataAssets) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
// def wraps the assets to return the default file if the file doesn't exist
|
// def wraps the assets to return the default file if the file doesn't exist
|
||||||
def := func(name string) ([]byte, error) {
|
def := func(name string) ([]byte, error) {
|
||||||
// If the named asset exists, then return it directly.
|
// If the named asset exists, then return it directly.
|
||||||
|
@ -39,6 +49,9 @@ func (b *BindataAssets) Handler() http.Handler {
|
||||||
}
|
}
|
||||||
// If this is anything other than slash, we just return the default
|
// If this is anything other than slash, we just return the default
|
||||||
// asset. This default asset will handle the routing.
|
// asset. This default asset will handle the routing.
|
||||||
|
// Additionally, because we know we are returning the default asset,
|
||||||
|
// we need to set the default asset's content-type.
|
||||||
|
w.Header().Set("Content-Type", b.DefaultContentType)
|
||||||
return Asset(b.Default)
|
return Asset(b.Default)
|
||||||
}
|
}
|
||||||
return octets, nil
|
return octets, nil
|
||||||
|
@ -49,5 +62,5 @@ func (b *BindataAssets) Handler() http.Handler {
|
||||||
AssetInfo: AssetInfo,
|
AssetInfo: AssetInfo,
|
||||||
Prefix: b.Prefix,
|
Prefix: b.Prefix,
|
||||||
}
|
}
|
||||||
return http.FileServer(dir)
|
http.FileServer(dir).ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ const (
|
||||||
DebugDir = "ui/build"
|
DebugDir = "ui/build"
|
||||||
// DebugDefault is the default item to load if 404
|
// DebugDefault is the default item to load if 404
|
||||||
DebugDefault = "ui/build/index.html"
|
DebugDefault = "ui/build/index.html"
|
||||||
|
// DefaultContentType is the content-type to return for the Default file
|
||||||
|
DefaultContentType = "text/html; charset=utf-8"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AssetsOpts configures the asset middleware
|
// AssetsOpts configures the asset middleware
|
||||||
|
@ -36,8 +38,9 @@ func Assets(opts AssetsOpts) http.Handler {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assets = &dist.BindataAssets{
|
assets = &dist.BindataAssets{
|
||||||
Prefix: Dir,
|
Prefix: Dir,
|
||||||
Default: Default,
|
Default: Default,
|
||||||
|
DefaultContentType: DefaultContentType,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue