Jaguar class

Creates a Jaguar HTTP server.

Future<void> main() async {
  final server = Jaguar();
  server.get('/', (ctx) => 'Hello world!')
  await server.serve();
}
Mixed in types

Constructors

Jaguar({String address: "0.0.0.0", int port: 8080, bool multiThread: false, SecurityContext securityContext, bool autoCompress: false, ErrorWriter errorWriter, SessionManager sessionManager })
Constructs an instance of Jaguar with given configuration. [...]

Properties

after → List<RouteInterceptor>
final
autoCompress ↔ bool
Should the response be auto-compressed? [...]
read / write
before → List<RouteInterceptor>
final
errorWriter ErrorWriter
Used to write error pages in case of HTTP errors. [...]
read / write
log Logger
Logger used to log concise useful information about the request. This is also available in Context so that interceptors and route handlers can also log.
final
onException → List<ExceptionHandler>
final
serializers → Map<String, CodecRepo>
Serializers for mimetypes
final
sessionManager SessionManager
Session manager to parse and update session data for requests. [...]
read / write
userFetchers → Map<Type, UserFetcher<AuthorizationUser>>
final
hashCode → int
The hash code for this object.
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

add(Iterable<Route> routes) → void
Adds all the given routes to be served
override
addRoute(Route route) Route
Adds the given route to be served
override
alsoTo(ConnectTo connection) → void
Start listening for requests also on connection
close() → Future<void>
Closes the server
group([String path = '' ]) GroupBuilder
Create a new route group
restart({bool logRequests: false }) → Future<void>
serve({bool logRequests: false }) → Future<void>
Starts serving the requests.
delete(String path, RouteHandler handler, { Map<String, String> pathRegEx, int statusCode: 200, String mimeType, String charset: kDefaultCharset, ResponseProcessor responseProcessor, List<RouteInterceptor> after, List<RouteInterceptor> before, List<ExceptionHandler> onException }) Route
Adds a route with DELETE method to be served
inherited
deleteJson(String path, RouteHandler handler, { Map<String, String> pathRegEx, int statusCode: 200, String mimeType, String charset: kDefaultCharset, ResponseProcessor responseProcessor: jsonResponseProcessor, List<RouteInterceptor> after, List<RouteInterceptor> before, List<ExceptionHandler> onException }) Route
Adds a route with DELETE method to be served
inherited
get(String path, RouteHandler handler, { Map<String, String> pathRegEx, int statusCode: 200, String mimeType, String charset: kDefaultCharset, ResponseProcessor responseProcessor, List<RouteInterceptor> after, List<RouteInterceptor> before, List<ExceptionHandler> onException }) Route
Adds a route with GET method to be served
inherited
getJson(String path, RouteHandler handler, { Map<String, String> pathRegEx, int statusCode: 200, String mimeType, String charset: kDefaultCharset, ResponseProcessor responseProcessor: jsonResponseProcessor, List<RouteInterceptor> after, List<RouteInterceptor> before, List<ExceptionHandler> onException }) Route
Adds a route with GET method to be served
inherited
html(String path, RouteHandler handler, { Map<String, String> pathRegEx, int statusCode: 200, String mimeType: MimeTypes.html, String charset: kDefaultCharset, ResponseProcessor responseProcessor, List<RouteInterceptor> after, List<RouteInterceptor> before, List<ExceptionHandler> onException }) Route
Adds a route with GET method to be served
inherited
json(String path, RouteHandler handler, { Map<String, String> pathRegEx, List<String> methods: const ['GET', 'PUT', 'POST', 'DELETE'], int statusCode: 200, String mimeType, String charset: kDefaultCharset, ResponseProcessor responseProcessor: jsonResponseProcessor, List<RouteInterceptor> after, List<RouteInterceptor> before, List<ExceptionHandler> onException }) Route
Adds a route to be served
inherited
map(Map<String, dynamic> handlers, { List<RouteInterceptor> before: const [], List<RouteInterceptor> after: const [], List<ExceptionHandler> onException: const [] }) → void
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
options(String path, RouteHandler handler, { Map<String, String> pathRegEx, int statusCode: 200, String mimeType, String charset: kDefaultCharset, ResponseProcessor responseProcessor, List<RouteInterceptor> after, List<RouteInterceptor> before, List<ExceptionHandler> onException }) Route
Adds a route with OPTIONS method to be served
inherited
patch(String path, RouteHandler handler, { Map<String, String> pathRegEx, int statusCode: 200, String mimeType, String charset: kDefaultCharset, ResponseProcessor responseProcessor, List<RouteInterceptor> after, List<RouteInterceptor> before, List<ExceptionHandler> onException }) Route
Adds a route with PATCH method to be served
inherited
post(String path, RouteHandler handler, { Map<String, String> pathRegEx, int statusCode: 200, String mimeType, String charset: kDefaultCharset, ResponseProcessor responseProcessor, List<RouteInterceptor> after, List<RouteInterceptor> before, List<ExceptionHandler> onException }) Route
Adds a route with POST method to be served
inherited
postJson(String path, RouteHandler handler, { Map<String, String> pathRegEx, int statusCode: 200, String mimeType, String charset: kDefaultCharset, ResponseProcessor responseProcessor: jsonResponseProcessor, List<RouteInterceptor> after, List<RouteInterceptor> before, List<ExceptionHandler> onException }) Route
Adds a route with POST method to be served
inherited
put(String path, RouteHandler handler, { Map<String, String> pathRegEx, int statusCode: 200, String mimeType, String charset: kDefaultCharset, ResponseProcessor responseProcessor, List<RouteInterceptor> after, List<RouteInterceptor> before, List<ExceptionHandler> onException }) Route
Adds a route with PUT method to be served
inherited
putJson(String path, RouteHandler handler, { Map<String, String> pathRegEx, int statusCode: 200, String mimeType, String charset: kDefaultCharset, ResponseProcessor responseProcessor: jsonResponseProcessor, List<RouteInterceptor> after, List<RouteInterceptor> before, List<ExceptionHandler> onException }) Route
Adds a route with PUT method to be served
inherited
route(String path, RouteHandler handler, { Map<String, String> pathRegEx, List<String> methods: const ['GET', 'PUT', 'POST', 'DELETE'], int statusCode: 200, String mimeType, String charset: kDefaultCharset, ResponseProcessor responseProcessor, List<RouteInterceptor> after, List<RouteInterceptor> before, List<ExceptionHandler> onException }) Route
Adds a route to be served
inherited
staticFile(String path, dynamic file, { Map<String, String> pathRegEx, int statusCode: 200, String mimeType, String charset: kDefaultCharset, ResponseProcessor responseProcessor }) Route
Serves requests at path with content of file [...]
inherited
staticFiles(String path, dynamic directory, { Map<String, String> pathRegEx, int statusCode: 200, String mimeType, String charset: kDefaultCharset, ResponseProcessor responseProcessor, bool stripPrefix: true, Future<Response> directoryLister(Directory directory) }) Route
Serves requests for static files at path from directory [...]
inherited
toString() → String
Returns a string representation of this object.
inherited
wsEcho(String path, { Map<String, String> pathRegEx, List<RouteInterceptor> after, List<RouteInterceptor> before, List<ExceptionHandler> onException }) Route
Example: server.wsEcho('/ws');
inherited
wsResponder(String path, WsOnConnect onConnect, { Map<String, String> pathRegEx, List<RouteInterceptor> after, List<RouteInterceptor> before, List<ExceptionHandler> onException }) Route
Example: server.wsEcho('/ws');
inherited
wsStream(String path, WsOnConnect onConnect, { Map<String, String> pathRegEx, List<RouteInterceptor> after, List<RouteInterceptor> before, List<ExceptionHandler> onException }) Route
Example: server.wsStream('/ws', (ctx, ws) => Stream.periodic);
inherited

Operators

operator ==(dynamic other) → bool
The equality operator.
inherited