- inside the palace 🏰 you have
Guard
s andHandler
s to serve yourRequest
s 😉 - batteries included 🔋
- validation including (
DTO
ORclass
) validation ⚔ - loggers (console/file) 📃
- middle-wares but we preferrer to call them
Guard
s 💂♂️ - hot-reload ⚡ =>
lighthouse
- .yaml file reader 🍨
- validation including (
here you can find examples repository
Future<void> main(List<String> args) async {
final router = PalaceRouter();
router.get('/greet_the_queen', (req, res) => res.write('Long Live The Queen'));
await router.openGates();
}
type of functions that
- return
Future
orvoid
- takes tow arguments
Request
reqResponse
res
a handler will be triggered when a match happened between the incoming request and the endpoint registered path
wrapper class around dart HttpRequest
will contains wrappers around the dart:io
HttpRequest
class and the httpRequest
itself
wrapper class around dart:io
HttpResponse
will have functions ease the process of responding to the incoming requests
like
res.json(data?)
will convert the given data toJSON
and sent it back to the userres.file(path)
res.notFound(data?)
=> 404res.internalServerError(data?)
=> 500res.accepted(data?)
=> 200res.created(data?)
=> 201- and so on....
if you respond to the request you will be ending the request life cycle this means guard still will be working but they can not modify the response any more
- register routes and the handler for each route
- register guards
- open the server
- close the server
type of functions that
-
return
Future
orvoid
-
takes three arguments
Request
reqResponse
resFunction
next
guards considered as extra layer before the Handlers layers
a guard can be registered for specific route or as global guard for any kind of requests
a guard can response to incoming requests since the have access to the instance of the incoming request
a guard can preform any kind of logic before or after the handler be triggered