lite_server 0.4.1
lite_server: ^0.4.1 copied to clipboard
A lightweight, secure, and high-performance HTTP server wrapper for Dart with built-in security features, request timeout protection, static file serving, CORS support, and comprehensive logging capabilities.
Changelog #
All notable changes to this project are documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.4.1 - 2026-09-10 #
Breaking Changes #
- Route constructors take a named
pathargument instead of a positional one:HttpRoute.get(path: '/users', ...)andHttpStaticRoute(path: '/assets', directoryPath: ...).
0.4.0 - 2026-09-04 #
Breaking Changes #
- Path parameters must be non-empty, so
/user/no longer matches/user/<id>. - Invalid route configuration throws
ArgumentErrorinstead ofException. Registering the same path and method twice is rejected at startup. - Static routes serve
GETandHEADby default (wasGETonly).
Fixed #
- Routes are keyed by path and method.
GET /user/<id>andPOST /user/<id>used to overwrite each other in the route map, leaving one unreachable behind a405. - Request size limits are enforced while the body is read. A chunked request
without
Content-Lengthpreviously bypassed the limit entirely. - Path parameters accept and decode percent-encoded values
(
/user/John%20Doe→id: John Doe). - Literal characters in route paths are escaped (
/report.jsonno longer matches/reportxjson). - A path parameter can no longer capture across
/. - The request timeout timer is always cancelled (early returns previously leaked a timer that fired ~30s later).
- Errors raised after the response is closed no longer produce an unhandled
asynchronous error while trying to send a
500. onErrorpassed tolistenis used as a fallback error handler (it was accepted and ignored).- Static routes only match the mount path and paths under it
(
/imagesEVILno longer hits/images). - Nested static routes no longer strip the wrong path prefix.
- Directory listings HTML-escape file names and hide dotfiles (e.g.
.env). - CORS:
Access-Control-Allow-Originechoes a single allowed origin, never pairs*with credentials, and sendsVary: Originwhen the origin varies. - Response messages are stripped of control characters (no status-line header injection).
status()keeps a content type set earlier instead of clearing it.LiteServerLoggerfile handles are per-instance and roll over daily (they were static and shared across loggers).LoggerControllerdoes not create a log directory when nothing will be written.- Multipart parts use
BytesBuilderand stream as they arrive (no O(n²) rebuild per chunk). content-dispositionsplits on the first=only (file names with=survive).isMultipartchecks the media type, not only a boundary parameter.- Unknown MIME types serve as
application/octet-streaminstead of500. analysis_options.yamllint disables moved toanalyzer: errors:so they merge with the included rule set.
Added #
HttpRoute.put,.patch,.delete,.head, and.optionsHttpRoutePayload.path,.parameter(), and.extra<T>()readBodyAsBytes(),readBodyAsJson<T>()HttpMultiPartData.name,.filename,.contentType,.isFile, and.text()response.text(), and optionalmessageon error helpersHttpRequestTooLargeExceptionandHttpMultipartExceptionLoggerController.printLogsandLiteServerLogger.close()405responses include anAllowheader- Static routes honour
If-Modified-Since/Last-Modified(304) - Test suite for routing, request handling, static-file security, CORS, logging, and multipart parsing
Changed #
- Files are streamed instead of buffered in memory (
response.file()and static routes). - Route patterns are compiled once at startup.
listenreturns itsStreamSubscriptionand acceptslogStartup.- Method matching is case-insensitive.
- Trailing slashes are ignored when matching.
- A
messagewithout abodyis written as the response body.
0.3.0 - 2024-12-19 #
- Add request timeout protection (30s default)
- Add request size limits (10MB default)
- Add directory traversal attack prevention
- Add file extension restrictions for static routes
- Add forbidden response helper
- Optimize route matching performance
- Improve error handling and logging
- Update dependencies
0.2.4 - 2024-11-15 #
- Updated dependencies.
- Updated
response.ok()
0.2.3 - 2024-10-20 #
- Fixed nested route multiple dynamic path parameter parse bug ex.
/<foo>/<bar>/<deep>/<path>/...
0.2.1 - 2024-09-10 #
- Updated Readme.md
0.2.0 - 2024-08-25 #
- Updated
LoggerControllerwork logic; - Relocated
LiteServer(controllers: [...])=>LiteServer(...).listen(httpServer, controllers: [...])
0.1.5 - 2024-07-15 #
- Updated
CorsOriginControllerOPTIONSmethod response;
0.1.4 - 2024-06-30 #
- Updated LoggerController
0.1.3 - 2024-06-10 #
- Updated Request Logger
- Renamed
HttpServicetoHttpControllerand update error handle logic - Renamed
HttpServiceBehaviortoHttpControllerBehavior
0.1.2 - 2024-05-20 #
- Updated Example
0.1.1 - 2024-05-05 #
- Fixed typos
- Fixed minor issues
0.1.0 - 2024-04-15 #
- Fixed allowed methods check logic
0.0.9 - 2024-03-25 #
- Added missing
serviceargument forHttpStaticRoute
0.0.8 - 2024-03-10 #
- Updated
CorsOriginService
0.0.7 - 2024-02-20 #
- Fixed null-check issue.
0.0.6 - 2024-02-05 #
- Updated response helper extension methods.
Not need to call .close() anymore - Updated logger service
0.0.5 - 2024-01-15 #
- Renamed
HttpServiceBehavior.modeOn=>HttpServiceBehavior.next - Renamed
HttpServiceBehavior.cutOff=>HttpServiceBehavior.revoke - Updated helpers extensions
0.0.4 - 2024-01-05 #
- Updated Logger
printLogslogic
0.0.3 - 2023-12-20 #
- Moved logging params to LoggerService
- Added
onErrorhandler to services - HttpServices now return
HttpServiceBehavior
0.0.2 - 2023-12-10 #
- Updated LiteServer initialize method
0.0.1 - 2023-12-01 #
- Initial version.