Namdak Tonpa 8 years ago
parent
commit
4aa06b0de5
2 changed files with 4 additions and 2 deletions
  1. 2 0
      include/nitro.hrl
  2. 2 2
      src/nitro.erl

+ 2 - 0
include/nitro.hrl

@@ -1,6 +1,8 @@
 -ifndef(NITRO_HRL).
 -define(NITRO_HRL, true).
 
+-define(CTX, (get(context))).
+
 -define(DEFAULT_BASE, {?ELEMENT_BASE(undefined)}).
 -define(DEFAULT_BASE_TAG(Tag), {?ELEMENT_BASE(undefined,Tag,undefined)}).
 -define(ELEMENT_BASE(Module), ?ELEMENT_BASE(Module,undefined,undefined)).

+ 2 - 2
src/nitro.erl

@@ -1,6 +1,6 @@
 -module(nitro).
 -include_lib("n2o/include/n2o.hrl").
--include("nitro.hrl").
+-include_lib("nitro/include/nitro.hrl").
 -compile(export_all).
 -behaviour(application).
 -export([start/2, stop/1, init/1]).
@@ -168,7 +168,7 @@ state(Key,Value) -> erlang:put(Key,Value).
 
 redirect({http,Url}) -> n2o:header(<<"Location">>,nitro_conv:to_binary(Url)), nitro:state(status,302), [];
 redirect(Url) -> nitro:wire(#jq{target='window.top',property=location,args=simple,right=Url}).
-header(K,V) -> nitro:context((?CTX)#cx{req=cowboy_req:set_resp_header(K,V,?REQ)}).
+header(K,V) -> nitro:context((?CTX)#cx{req=cowboy_req:set_resp_header(K,V,?CTX#cx.req)}).
 
 % Convert and Utils API