Skip to content

Commit

Permalink
fix(tiproxy): fix the wrong file ext for tiproxy config (#1656)
Browse files Browse the repository at this point in the history
  • Loading branch information
baurine authored Mar 15, 2024
1 parent df2799d commit aa6dbf6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/apiserver/debugapi/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ var commonParamPprofDebug = endpoint.APIParamEnum("debug", false, []endpoint.Enu
{Value: "2", DisplayAs: "Text Format"},
})

var commonParamConfigFormat = endpoint.APIParamEnum("format", false, []endpoint.EnumItemDefinition{
{Value: "toml"},
{Value: "json"},
})

var apiEndpoints = []endpoint.APIDefinition{
// TiDB Endpoints
{
Expand Down Expand Up @@ -445,6 +450,9 @@ var apiEndpoints = []endpoint.APIDefinition{
Component: topo.KindTiProxy,
Path: "/api/admin/config",
Method: resty.MethodGet,
QueryParams: []endpoint.APIParamDefinition{
commonParamConfigFormat,
},
},
{
ID: "tiproxy_pprof",
Expand Down
4 changes: 4 additions & 0 deletions pkg/apiserver/debugapi/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ func getExtFromContentTypeHeader(contentType string) string {
return ".txt"
}

if mediaType == "application/toml" {
return ".toml"
}

exts, err := mime.ExtensionsByType(mediaType)
if err == nil && len(exts) > 0 {
// Note: the first element might not be the most common one
Expand Down

0 comments on commit aa6dbf6

Please sign in to comment.