pharaoh library
Classes
- CookieOpts
- expires The time at which the cookie expires.
- InMemoryStore
- MimeType
- Pharaoh
- PharaohErrorBody
- Request
- RequestContext
- Response
- Session
- SessionStore
- ViewEngine
- ViewRenderData
Extensions
Properties
- sessionPreResponseHook → ReqResHook
-
final
- viewRenderHook → ReqResHook
-
final
Functions
-
bakeCookie(
String name, Object? value, CookieOpts opts) → Cookie -
bodyParser(
Request req, Response res, NextFunction next) → dynamic -
catchTopLevelErrors(
void callback(), void onError(dynamic error, StackTrace)) → void -
Run
callbackand capture any errors that would otherwise be top-leveled. -
contentTypeToString(
ContentType type, {String charset = 'utf-8'}) → String -
executeHandlers(
Iterable handlers, ReqRes reqRes) → Future< ReqRes> -
getHttpMethod(
HttpRequest req) → HTTPMethod -
hashData(
dynamic sess) → String -
logRequests(
Request req, Response res, NextFunction next) → dynamic -
safeCompare(
String a, String b) → bool -
sessionMdw(
{String name = Session.name, String? secret, bool saveUninitialized = true, bool rolling = false, bool resave = false, GenSessionIdFunc? genId, SessionStore? store, CookieOpts cookie = const CookieOpts(httpOnly: true, secure: false)}) → Middleware -
nameThe name of the session ID cookie to set in the response (and read from in the request). The default value ispharaoh.sid.saveUninitializedForces a session that is "uninitialized" to be saved to the store. A session is uninitialized when it is new but not modified. Default value istruerollingThe expiration is reset to the original maxAge, resetting the expiration countdown and forces the session identifier cookie to be set on every response.resaveForces the session to be saved back to the session store, even if the session was never modified during the request. Default value isfalsegenIdFunction to call to generate a new session ID. Provide a function that returns a string that will be used as a session ID. Session ID is generated fromuuid-v4by default.storeThe session store instance, defaults to a new MemoryStore instance.cookieSettings object for the session ID cookie. The default value is{ path: '/', httpOnly: true, secure: false, maxAge: null }.secretThis is the secret used to sign the session ID cookie. You can also provide it incookie.secretoptions. Butsecretwill will be used if both are set. -
signValue(
String value, String secret) → String -
Sign the given
valuewithsecret. -
unsignValue(
String input, String secret) → String? -
Unsign and decode the given
inputwithsecret, returningnullif the signature is invalid. -
useRequestHandler(
RequestHandler handler) → Middleware -
useShelfMiddleware(
dynamic middleware) → Middleware - Use this hook to transform any shelf middleware into a Middleware that Pharaoh can use.
Typedefs
-
GenSessionIdFunc
= FutureOr<
String> Function(Request request) -
Middleware
= FutureOr<
void> Function(Request req, Response res, NextFunction next) -
NextFunction<
Next> = dynamic Function([dynamic result, Next? chain]) -
OnErrorCallback
= FutureOr<
Response> Function(PharaohError error, Request req, Response res) - PharaohError = ({Object exception, StackTrace trace})
- ReqRes = ({Request req, Response res})
-
ReqResHook
= FutureOr<
ReqRes> Function(ReqRes reqRes) - RequestHandler = FutureOr Function(Request req, Response res)
- ShelfBody = Body
-
ShelfMiddlewareType2
= FutureOr<
Response> Function(Request)