Skip to content

Commit

Permalink
fix https example
Browse files Browse the repository at this point in the history
  • Loading branch information
v1rtl committed Aug 3, 2023
1 parent bcfce0d commit 437ebf5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
7 changes: 5 additions & 2 deletions app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,12 @@ export class App<
throw new Response(res._body, res._init)
}

handler = async (_req: Request, conn: Deno.Conn) => {
handler = async (
_req: Request,
conn?: Deno.Conn,
) => {
const req = _req.clone() as Req
req.conn = conn
req.conn = conn! as unknown as Deno.Conn
const res: DummyResponse = {
_init: {
headers: new Headers(
Expand Down
11 changes: 11 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions examples/https/mod.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { App } from '../../app.ts'
import { serveTls } from 'https://deno.land/std@0.197.0/http/server.ts'

const app = new App()

app.get('/', async (req, res) => {
await res.send(`Hello World from ${req.protocol}`)
})

await serveTls(app.handler, {
port: 3000,
onError: app.onError,
certFile: './cert.pem',
keyFile: './key.pem',
})
Deno.serve(
{
port: 3000,
cert: await Deno.readTextFile('./cert.pem'),
key: await Deno.readTextFile('./key.pem'),
},
(req) => app.handler(req),
)
2 changes: 1 addition & 1 deletion tests/core/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ describe('Subapps', () => {
),
})

subApp.get('/route', async (req, res, next) => await next('you'))
subApp.get('/route', async (_req, _res, next) => await next('you'))

app.use('/subapp', subApp)
;(await makeFetch(app.handler)('/subapp/route'))
Expand Down

0 comments on commit 437ebf5

Please sign in to comment.