2

I was trying to follow along with one of the Dart HttpServer examples from GitHub, and, while it does show how to create and handle routes, I'm still at a loss on how to produce and send an HttpResponce in response to a specific url being requested.

For example, while working with WebAPI, I would have an Api Controller, in which I could explicitly define an action for GET, PUT, DELETE and POST verbs, and return an appropriate HttpResponse with a resource from each such method.

Does anyone know how this typical CRUD business is done using Dart as an Http server?

1 Answer 1

2

Once you receive a HttpRequest you need to use the response attribute to answer.

void sendOk(HttpRequest request, [content]) {
  request.response
    ..statusCode = HttpStatus.OK
    ..write(content)
    ..close()
    ;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.