[](https://gitter.im/redstone-dart/redstone?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Redstone is an annotation driven web server micro-framework for Dart and influenced by Flask. It is based on shelf so you may also use any shelf middleware you like with Redstone.
Redstone allows you to easily publish functions through a web interface, by just adding some annotations to them.
import 'package:redstone/redstone.dart' as web;
@web.Route("/")
helloWorld() => "Hello, World!";
main() {
web.setupConsoleLog();
web.start();
}
To install, set the redstone: "^0.6.4"
constraint to your pubspec.
dependencies:
redstone: "^0.6.4"
The following plugins are also available for this version:
redstone_mapper: 0.2.0-beta.1+1
redstone_mapper_mongo: 0.2.0-beta.1
redstone_mapper_pg: 0.2.0-beta.2+2
redstone_web_socket: 0.1.0-beta.1
Check out our wiki! :)
Drop package:crypto. Update other package dependencies and fix some strong-mode issues. Also fixes definitions of == and hashCode.
Bug fix: http_body_parser tries to parse body of GET Requests
In this version, the minimum SDK version was bumped to 1.13.0 because of the Boring SSL update.
NOTE: this is a pre-release version!
secureOptions
in the server.start() function
takes a #context
which is a SecurityContext
. See example/https.dart
for more usage example.NOTE: this is a pre-release version!
headers
to chain.forward()
request.handlerPath
property (see shelf.Request.handlerPath)NOTE: this is a pre-release version!
shared
and logSetUp
optional parameters to the start()
functionNOTE: this is a pre-release version!
request.queryParams
to request.queryParameters
request.pathParams
to request.urlParameters
NOTE: this is a pre-release version!
Version highlights:
chain.forward()
function, which allows routes, interceptors and error handlers to internally dispatch a request to another resourcechain.createResponse()
function, which can be used to easily create shelf.Response
objectsasync/await
(see breaking changes)BREAKING CHANGES:
redstone/server.dart
to redstone/redstone.dart
QueryMap
to DynamicMap
Route.matchSubPaths
property (route_hierarchical
supports this by default now)setUp()
and tearDown()
to redstoneSetUp()
and redstoneTearDown()
. This avoids conflicts with the unittest package, if redstone is imported without a lib prefix.redstoneSetUp()
now returns a Future
. You need to wait for its completion before dispatching any request.authenticateBasic()
top level functionparseAuthorizationHeader()
top level function to the request
object (request.parseAuthorizationHeader()
)chain.interrupt()
function. chain.next()
and chain.abort()
functions now return a Future<shelf.Response>
. It's necessary to wait for the completion of the returned future when calling one of these functions, although, it's now possible to use them with async/await expressions. See the example below.chain.redirect()
function now returns a shelf.Response
showErrorPage
to false@Inject
. Although, they now also accept the @Attr
annotation, which binds a parameter with a request attribute.Manager
object are now getters.RouteHandler
to DynamicRoute
Handler
to DynamicHandler
DynamicRoute
and RouteWrapper
do not receive the pathSegments
map anymore, although, it can be accessed through the request.pathSegments
propertyrequest.queryParams
is now a DynamicMap<String, List<String>>
. Also, you can now use the @QueryParam
annotation with List
objectsExample: CORS Interceptor
import 'package:redstone/redstone.dart';
import "package:shelf/shelf.dart" as shelf;
@Interceptor(r'/.*')
handleCORS() async {
if (request.method != "OPTIONS") {
await chain.next();
}
return response.change(headers: {"Access-Control-Allow-Origin": "*"});
}
autoCompress
parameter to the start()
function.Route.statusCode
and DefaultRoute.statusCode
parameters.Note: this version requires Dart 1.7 or above
QueryMap
with the dot notation is not working properly.Manager.findMethods()
should include inherited methods.Manager.getInjector()
and Manager.createInjector()
methods, which allow plugins to retrieve objects from di modules more easily.Manager.findFunctions()
, Manager.findClasses()
and Manager.findMethods()
methods, which allow plugins to scan imported libraries.Manager.getShelfHandler()
and Manager.setShelfHandler()
methods, which allow plugins to access and replace the current installed shelf handler.matchSubPaths = true
, the requested subpath can be assigned to a parameter (see issue #36).shelf.Pipeline
per request.Manager.addRouteWrapper()
method, which allows plugins to modify routes that are annotated with a specific annotation.ErrorResponse
class. A route can return or throw an ErrorResponse, to respond a request with a status code different than 200. Future
(Plugin API).QueryMap
class, a Map wrapper that allows the use of the dot notation to retreive its values (Thanks to digitalfiz issue #18)app.request.queryParams
, app.request.headers
and app.request.attributes
now returns a QueryMap.handleRequest(HttpRequest)
method.di
shelf.Request.hijack()
method is now supported (although it does not work in unit tests)stack_trace
package to print stack traces.HttpRequest
and HttpResponse
. If you need to inspect or modify the response, you can use the global response
object (see documentation)@DefaultRoute
annotation (see documentation)serveRequests(Stream<HttpRequest> requests)
method, which is an alternative to the start()
method.@Install
and @Ignore
(see documentation)Route.matchSubPaths
property (see issue #5)ErrorHandler.urlPattern
property (check documentation for details)parseAuthorizationHeader()
method.authenticateBasic()
method.jailRoot = true
and followLinks = false
. You can change these flags through start()
method.null
if they call request.body
(although request.bodyType is still filled). If your interceptor need to inspect the request body, you can set Interceptor.parseRequestBody = true
.Route.allowMultipartRequest = true
.chain.interrupt()
method are now optional.abort()
, redirect()
and chain.interrupt()
methods. (see issue #3).chain.next()
now receives a callback, instead of returning a Future
chain.interrupt()
is not closing the HttpResponse
streamAdd this to your package's pubspec.yaml file:
dependencies:
redstone: ^0.6.6
You can install packages from the command line:
with pub:
$ pub get
Alternatively, your editor might support pub get
.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:redstone/redstone.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
0.6.8 | Dec 12, 2016 |
|
|
0.6.7 | Jul 22, 2016 |
|
|
0.6.6 | May 21, 2016 |
|
|
0.6.5 | Feb 27, 2016 |
|
|
0.6.4 | Jan 25, 2016 |
|
|
0.6.2 | Dec 15, 2015 |
|
|
0.6.1 | Nov 24, 2015 |
|
|
0.6.0+1 | Sep 15, 2015 |
|
|
0.6.0 | Sep 15, 2015 |
|
|
0.5.21+1 | Apr 14, 2015 |
|
|
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
55
|
Health:
Code health derived from static analysis.
[more]
|
--
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
--
|
Overall:
Weighted score of the above.
[more]
|
28
|
This package version is not analyzed, because it is more than two years old. Check the latest stable version for its analysis.
The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.
Running dartdoc
failed. (-10 points)
Make sure dartdoc
runs without any issues.
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=1.13.0 <2.0.0 |