websrv: redirect
This commit is contained in:
		@@ -23,6 +23,11 @@ http.createServer(async (req, res, r) => {
 | 
			
		||||
    type = "text/html",
 | 
			
		||||
    body
 | 
			
		||||
  }) => res.writeHead(code, { "Content-Type": `${type}; charset=utf-8` }).end(body);
 | 
			
		||||
  
 | 
			
		||||
  res.redirect = target => res.writeHead(301, {
 | 
			
		||||
    "Cache-Control": "no-cache, public",
 | 
			
		||||
    "Location": target
 | 
			
		||||
  }).end();
 | 
			
		||||
 | 
			
		||||
  !(r = router.routes.getRoute(req.url.pathname, req.method)) ? res.writeHead(404).end(`404 - ${req.url.pathname}`) : await r(req, res);
 | 
			
		||||
  console.log(`[${(new Date()).toLocaleTimeString()}] ${res.statusCode} ${req.method}\t${req.url.pathname}`);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user