@@ -6,6 +6,7 @@ import config from "./config.ts";
66import { contextMiddleware , getRequestLog } from "./context.ts" ;
77import { hasKey , verify } from "./crypto.ts" ;
88import handler from "./handler.ts" ;
9+ import { setMetaHeader } from "./util.ts" ;
910
1011const app = new Hono ( ) ;
1112
@@ -14,6 +15,12 @@ app.use(contextMiddleware);
1415// use context's requestlog for server logs
1516app . use ( logger ( ( ...args ) => getRequestLog ( ) . log ( ...args ) ) ) ;
1617
18+ // add deploy header to responses
19+ app . use ( async ( c , next ) => {
20+ await next ( ) ;
21+ setMetaHeader ( c , "deploy" , config . deployId ) ;
22+ } ) ;
23+
1724if ( config . mainRedirect ) {
1825 app . get ( "/" , ( c ) => {
1926 return c . redirect ( config . mainRedirect ! ) ;
@@ -38,12 +45,8 @@ app.post("/:id/:token", async (c) => {
3845 res = new Response ( res . body , res ) ;
3946
4047 // set metadata headers
41- meta = {
42- "deploy" : config . deployId ,
43- ...meta ,
44- } ;
4548 for ( const [ key , value ] of Object . entries ( meta ) ) {
46- res . headers . set ( `x-webhook-filter- ${ key } ` , value ) ;
49+ setMetaHeader ( c , key , value ) ;
4750 }
4851
4952 // remove other headers that don't make sense here
0 commit comments