Orientação gerada a partir de informações públicas. Apenas para referência.
Jaguar é um framework de servidor HTTP de alto desempenho e pronto para produção em Dart, projetado para velocidade, simplicidade e extensibilidade. Desenvolvido com foco na experiência do desenvolvedor, permite o desenvolvimento rápido de serviços backend escaláveis e APIs web. O Jaguar suporta programação assíncrona e oferece arquitetura modular, tornando-o ideal tanto para pequenos projetos quanto para aplicações em grande escala. Funciona sem problemas em múltiplas plataformas, incluindo Android, iOS, macOS, Windows e Linux.
Casos de uso
Construindo APIs RESTful
Criando microserviços
Desenvolvendo servidores web em tempo real
Implementando lógica de back-end para aplicativos móveis
Executando aplicativos Dart do lado do servidor
Principais recursos
Servidor HTTP de alto desempenho
Design modular e extensível
Suporte embutido para async/await
Rotas fáceis e integração de middleware
Compatibilidade multiplataforma
Indicado para
Desenvolvedores Dart construindo serviços de backend
Equipes que precisam de servidores HTTP rápidos e confiáveis
Projetos que exigem APIs leves e escaláveis
Backends de aplicativos móveis usando Dart
Aplicações Dart de ponta a ponta
Considerações
Ecosistema limitado em comparação com frameworks maduros
Requer entendimento do modelo assíncrono do Dart
Comunidade menor do que alternativas como Express.js ou Spring Boot
README original
Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.
Jaguar
Jaguar is a full-stack production ready HTTP server framework built to be fast, simple and intuitive.
Getting started
Familiar way to write routes
Jaguar class provides methods get, put, post,
delete and options to quickly add route handlers for specific HTTP methods.
main() async {
final server = Jaguar(); // Serves the API at localhost:8080 by default// Add a route handler for 'GET' method at path '/hello'
server.get('/hello', (Context ctx) => 'Hello world!');
await server.serve();
}
Powerful route matching
Easily define and access Path parameters
Path segments prefixed with : can match any value and are also captured as path variables. Path variables can be accessed
using pathParams member of Context object.
main(List<String> args) async {
final quotes = <String>[
'But man is not made for defeat. A man can be destroyed but not defeated.',
'When you reach the end of your rope, tie a knot in it and hang on.',
'Learning never exhausts the mind.',
];
final server = Jaguar();
server.get('/api/quote/:index', (ctx) { // The magic!finalint index = ctx.pathParams.getInt('index', 1); // The magic!return quotes[index + 1];
});
await server.serve();
}
A path can have multiple path variables.
A path variable can appear at any position in the path.
A path variable can be matched against a Regular expression.
getInt, getDouble, getNum and getBool methods can be used to easily typecast path variables.
Using * as the final path segment captures/matches all following segments.
Easily access Query parameters
Query parameters can be accessed using queryParams member of Context object.
main(List<String> args) async {
final quotes = <String>[
'But man is not made for defeat. A man can be destroyed but not defeated.',
'When you reach the end of your rope, tie a knot in it and hang on.',
'Learning never exhausts the mind.',
];
final server = Jaguar();
server.get('/api/quote', (ctx) {
finalint index = ctx.queryParams.getInt('index', 1); // The magic!return quotes[index + 1];
});
await server.serve();
}
getInt, getDouble, getNum and getBool methods can be used to easily typecast query parameters into desired type.
One liner to access Forms
A single line is all it takes to obtain a form as a Map<String, String> using method bodyAsUrlEncodedForm
on Request object.
The method staticFiles adds static files to Jaguar server. The first argument determines
the request Uri that much be matched and the second argument determines the directory from which the target files are fetched.
main() async {
final server = Jaguar();
server.staticFiles('/static/*', 'static'); // The magic!await server.serve();
}