1- import { http , httpErrors , log } from "./deps.ts" ;
1+ import { httpErrors , log } from "./deps.ts" ;
22import config from "./lib/config.ts" ;
33import handler from "./lib/handler.ts" ;
44import { requestLog } from "./lib/util.ts" ;
@@ -19,7 +19,7 @@ function setupLogs() {
1919 } ) ;
2020}
2121
22- async function handleRequest ( req : Request , connInfo : http . ConnInfo ) : Promise < Response > {
22+ async function handleRequest ( req : Request , info : Deno . ServeHandlerInfo ) : Promise < Response > {
2323 const reqLog = requestLog ( req . headers ) ;
2424
2525 let res : Response ;
@@ -33,7 +33,7 @@ async function handleRequest(req: Request, connInfo: http.ConnInfo): Promise<Res
3333 }
3434 } catch ( err ) {
3535 if ( err instanceof httpErrors . HttpError && err . expose ) {
36- reqLog . warning ( `http error: ${ err . message } ` ) ;
36+ reqLog . warn ( `http error: ${ err . message } ` ) ;
3737 res = new Response ( err . message , { status : err . status } ) ;
3838 } else {
3939 reqLog . critical ( err ) ;
@@ -60,7 +60,7 @@ async function handleRequest(req: Request, connInfo: http.ConnInfo): Promise<Res
6060
6161 // log request
6262 const respLen = res . headers . get ( "content-length" ) || 0 ;
63- const addr = connInfo . remoteAddr as Deno . NetAddr ;
63+ const addr = info . remoteAddr ;
6464 reqLog . info (
6565 `http: ${ addr . hostname } :${ addr . port } - ${ req . method } ${ req . url } ${ res . status } ${ respLen } ` ,
6666 ) ;
@@ -72,13 +72,13 @@ if (import.meta.main) {
7272 setupLogs ( ) ;
7373
7474 if ( ! config . signKey ) {
75- log . warning ( "url signing disabled" ) ;
75+ log . warn ( "url signing disabled" ) ;
7676 }
7777
7878 log . info ( `starting webserver on ${ config . hostname } :${ config . port } ` ) ;
79- http . serve ( handleRequest , {
79+ Deno . serve ( {
8080 hostname : config . hostname ,
8181 port : config . port ,
8282 onListen : ( ) => log . info ( `listening on ${ config . hostname } :${ config . port } ` ) ,
83- } ) ;
83+ } , handleRequest ) ;
8484}
0 commit comments