Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
0980fa2d
Unverified
Commit
0980fa2d
authored
Sep 26, 2019
by
Jonah Williams
Committed by
GitHub
Sep 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Serve every html file under web (#41386)
parent
05097916
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
1 deletion
+60
-1
web_fs.dart
packages/flutter_tools/lib/src/build_runner/web_fs.dart
+10
-1
project.dart
packages/flutter_tools/lib/src/project.dart
+3
-0
asset_server_test.dart
...utter_tools/test/general.shard/web/asset_server_test.dart
+47
-0
No files found.
packages/flutter_tools/lib/src/build_runner/web_fs.dart
View file @
0980fa2d
...
...
@@ -265,7 +265,16 @@ class AssetServer {
Directory
partFiles
;
Future
<
Response
>
handle
(
Request
request
)
async
{
if
(
request
.
url
.
path
.
contains
(
'stack_trace_mapper'
))
{
if
(
request
.
url
.
path
.
endsWith
(
'.html'
))
{
final
Uri
htmlUri
=
flutterProject
.
web
.
directory
.
uri
.
resolveUri
(
request
.
url
);
final
File
htmlFile
=
fs
.
file
(
htmlUri
);
if
(
htmlFile
.
existsSync
())
{
return
Response
.
ok
(
htmlFile
.
readAsBytesSync
(),
headers:
<
String
,
String
>{
'Content-Type'
:
'text/html'
,
});
}
return
Response
.
notFound
(
''
);
}
else
if
(
request
.
url
.
path
.
contains
(
'stack_trace_mapper'
))
{
final
File
file
=
fs
.
file
(
fs
.
path
.
join
(
artifacts
.
getArtifactPath
(
Artifact
.
engineDartSdkPath
),
'lib'
,
...
...
packages/flutter_tools/lib/src/project.dart
View file @
0980fa2d
...
...
@@ -636,6 +636,9 @@ class WebProject {
/// The 'lib' directory for the application.
Directory
get
libDirectory
=>
parent
.
directory
.
childDirectory
(
'lib'
);
/// The directory containing additional files for the application.
Directory
get
directory
=>
parent
.
directory
.
childDirectory
(
'web'
);
/// The html file used to host the flutter web application.
File
get
indexFile
=>
parent
.
directory
.
childDirectory
(
'web'
)
...
...
packages/flutter_tools/test/general.shard/web/asset_server_test.dart
0 → 100644
View file @
0980fa2d
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/build_runner/web_fs.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:shelf/shelf.dart'
;
import
'../../src/common.dart'
;
import
'../../src/testbed.dart'
;
void
main
(
)
{
Testbed
testbed
;
AssetServer
assetServer
;
setUp
(()
{
testbed
=
Testbed
(
setup:
()
{
fs
.
file
(
fs
.
path
.
join
(
'lib'
,
'main.dart'
))
.
createSync
(
recursive:
true
);
fs
.
file
(
fs
.
path
.
join
(
'web'
,
'index.html'
))
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'hello'
);
assetServer
=
AssetServer
(
FlutterProject
.
current
(),
fs
.
path
.
join
(
'main'
));
}
);
});
test
(
'can serve an html file from the web directory'
,
()
=>
testbed
.
run
(()
async
{
final
Response
response
=
await
assetServer
.
handle
(
Request
(
'GET'
,
Uri
.
parse
(
'http://localhost:8080/index.html'
)));
expect
(
response
.
headers
,
<
String
,
String
>{
'Content-Type'
:
'text/html'
,
'content-length'
:
'5'
});
expect
(
await
response
.
readAsString
(),
'hello'
);
}));
test
(
'handles a missing html file from the web directory'
,
()
=>
testbed
.
run
(()
async
{
final
Response
response
=
await
assetServer
.
handle
(
Request
(
'GET'
,
Uri
.
parse
(
'http://localhost:8080/foobar.html'
)));
expect
(
response
.
statusCode
,
404
);
}));
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment