Comments (3)
@kiesman99 can you check if this is a problem with package:shelf_router
or package:shelf
?
from dart-neats.
Please re-open if this is related to package:shelf_router
:D
from dart-neats.
@kiesman99 and @jonasfj yes that might be the problem with package:shelf
not sure cause the Response.ok()
was from that package. So basically the response needs headers. If we haven't defined headers, that will think it was a file and the content of a file cannot be viewed directly in the web so it will download the file. If the response we expected was text
, write the extension to the file downloaded and open it. It will show the content. If it is json data append the extension to the file and open it, you will able to see the content/response we need. So that, if we add headers to the response it will preview in that format.
This is your sample code data you expected right @kiesman99 ??
So here is another scenario (mine)
import 'package:shelf/shelf.dart';
import 'package:shelf_router/shelf_router.dart';
import 'package:shelf/shelf_io.dart' as io;
class Data{
Handler get handler {
final router = Router();
router.get('/', (Request req) {
return Response.ok(
'Hello there ππ»',
// Specifying header solved my emoji issues too.
// Now I can even write up emojis π.
headers: {'Content-Type': 'text/plain'},
);
});
return router;
}
}
void main() async {
final service = Data();
await io.serve(app, 'localhost', 1031).then(
(value) => print('API running at http://localhost:${value.port} π₯π₯π₯'));
}
My Output
Hope this clarified your issue. Please lemme know if not.
from dart-neats.
Related Issues (20)
- Doesn't work with Riverpod HOT 4
- router.get method should be able to pass context HOT 6
- add support to execute task in isolated (in background outside the main thread) HOT 3
- Migrate to use same pattern as UrlPattern HOT 3
- get current attempt times HOT 4
- [sanitize_html] Why section tag not allowed? HOT 1
- Should replace | with : in '/user/<userId|[0-9]+>', : looks more like a natural constraint symbol HOT 1
- consider updating the 'repository' pubspec fields with the repo+path_in_the_repo information HOT 4
- Put `lib/` directory into root of vendored package? HOT 4
- package retry -- terminology / semantics HOT 2
- consider this as a host for package:directories? HOT 5
- move top level pubspec into the tool/ dir?
- Enabling retry on any type of thrown errors HOT 2
- Callback for time left until next task. HOT 3
- Allow more/custom labels in `encodePemBlock` HOT 4
- Update to make RetryOptions final is breaking mocks HOT 2
- Could not start() after stop() HOT 1
- Proposal `obtain` / `getOrCreate` function HOT 1
- The updated RFC allows relative URLs in the `location` header, but the package rejects them.
- new update issue HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dart-neats.