dartrs 0.2.0 copy "dartrs: ^0.2.0" to clipboard
dartrs: ^0.2.0 copied to clipboard

outdatedDart 1 only

Simple Restful server implementation

Dart Restful Webserver #

A server to make development of restful webservices easy and fun

Getting Started #

var server = new RestfulServer();
server
  ..onGet("/echo", (request, params) => request.response.write("ECHO"))

POST/PUT/PATCH will handle parsing the body if provided callback has three parameters

  ..onPost("/post", (request, uriParams, body) => request.response.statusCode=HttpStatus.CREATED)   

Pre processing handler can be registed which will be invoked on every request

var old = server.preProcessor;
  
server.preProcessor = (request) {
    request.response.headers.contentType = ContentTypes.APPLICATION_JSON;
    old(request);
  };

HTTPS (SSL/TLS) #

Good folks at google decided to go with NSS see (https://developer.mozilla.org/en-US/docs/NSS/Tools) and documentation on SecureSocket.initialize(..) Luckily, default tests have a functioning key pair, which have been appropriated for testing needs (test/pkcert)

SecureSocket.initialize(database: "pkcert", password: 'dartdart', useBuiltinRoots: false);
var server = new RestfulServer.secure(port: 8443, certificateName: "localhost_cert");

Logging #

To see server messages you need to init logging_handlers

Logger.root.onRecord.listen(new PrintHandler());
0
likes
0
points
22
downloads

Publisher

unverified uploader

Weekly Downloads

Simple Restful server implementation

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

logging, logging_handlers

More

Packages that depend on dartrs