Merge pull request #11059 from JimMoen/fix-static-js-file-404

Fix static js file 404
This commit is contained in:
zhongwencool 2023-06-15 16:59:59 +08:00 committed by GitHub
commit 1a5684e35e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 53 deletions

View File

@ -68,19 +68,13 @@ start_listeners(Listeners) ->
}
}
},
Dispatch = [
{"/", cowboy_static, {priv_file, emqx_dashboard, "www/index.html"}},
{"/static/[...]", cowboy_static, {priv_dir, emqx_dashboard, "www/static"}},
{emqx_mgmt_api_status:path(), emqx_mgmt_api_status, []},
{'_', emqx_dashboard_not_found, []}
],
BaseMinirest = #{
base_path => emqx_dashboard_swagger:base_path(),
modules => minirest_api:find_api_modules(apps()),
authorization => Authorization,
security => [#{'basicAuth' => []}, #{'bearerAuth' => []}],
swagger_global_spec => GlobalSpec,
dispatch => Dispatch,
dispatch => dispatch(),
middlewares => [?EMQX_MIDDLE, cowboy_router, cowboy_handler]
},
{OkListeners, ErrListeners} =
@ -259,3 +253,20 @@ ensure_ssl_cert(Listeners = #{https := Https0}) ->
Listeners#{https => maps:from_list(Https1)};
ensure_ssl_cert(Listeners) ->
Listeners.
dispatch() ->
static_dispatch() ++ dynamic_dispatch().
static_dispatch() ->
StaticFiles = ["/editor.worker.js", "/json.worker.js", "/version"],
[
{"/", cowboy_static, {priv_file, emqx_dashboard, "www/index.html"}},
{"/static/[...]", cowboy_static, {priv_dir, emqx_dashboard, "www/static"}}
] ++
[{Path, cowboy_static, {priv_file, emqx_dashboard, "www" ++ Path}} || Path <- StaticFiles].
dynamic_dispatch() ->
[
{emqx_mgmt_api_status:path(), emqx_mgmt_api_status, []},
{'_', emqx_dashboard_not_found, []}
].

View File

@ -1,46 +0,0 @@
emqx_connector_api {
conn_get.desc:
"""List all connectors"""
conn_get.label:
"""List All Connectors"""
conn_id_delete.desc:
"""Delete a connector by ID"""
conn_id_delete.label:
"""Delete Connector"""
conn_id_get.desc:
"""Get the connector by ID"""
conn_id_get.label:
"""Get Connector"""
conn_id_put.desc:
"""Update an existing connector by ID"""
conn_id_put.label:
"""Update Connector"""
conn_post.desc:
"""Create a new connector"""
conn_post.label:
"""Create Connector"""
conn_test_post.desc:
"""Test creating a new connector by given ID <br/>
The ID must be of format '{type}:{name}'"""
conn_test_post.label:
"""Create Test Connector"""
id.desc:
"""The connector ID. Must be of format {type}:{name}"""
id.label:
"""Connector ID"""
}