@@ -103,79 +103,79 @@ func (h *aliasHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
103103 }
104104
105105 // data
106- data , fsPath := h .getResponseData (r )
107- h .logErrors (data .errors )
108- if data . File != nil {
106+ session , data := h .getSessionData (r )
107+ h .logErrors (session .errors )
108+ if session . file != nil {
109109 defer func () {
110- data . File .Close ()
110+ session . file .Close ()
111111 }()
112112 }
113113
114- if h .applyMiddlewares (h .inMiddlewares , w , r , data , fsPath ) {
114+ if h .applyMiddlewares (h .inMiddlewares , w , r , session , data ) {
115115 return
116116 }
117117
118- if ! data . AllowAccess {
119- if ! h .applyMiddlewares (h .postMiddlewares , w , r , data , fsPath ) {
118+ if ! session . allowAccess {
119+ if ! h .applyMiddlewares (h .postMiddlewares , w , r , session , data ) {
120120 h .page (w , r , data )
121121 }
122122 return
123123 }
124124
125- if data . NeedAuth {
125+ if session . needAuth {
126126 h .notifyAuth (w , r )
127127 }
128128
129- if data . AuthSuccess {
130- if data .requestAuth {
131- h .redirectWithoutRequestAuth (w , r , data )
129+ if session . authSuccess {
130+ if session .requestAuth {
131+ h .redirectWithoutRequestAuth (w , r , session , data )
132132 return
133133 }
134134
135- if data .redirectAction == addSlashSuffix {
136- redirect (w , r , data .prefixReqPath + "/" , h .autoDirSlash )
135+ if session .redirectAction == addSlashSuffix {
136+ redirect (w , r , session .prefixReqPath + "/" , h .autoDirSlash )
137137 return
138- } else if data .redirectAction == removeSlashSuffix {
139- redirect (w , r , data .prefixReqPath [:len (data .prefixReqPath )- 1 ], h .autoDirSlash )
138+ } else if session .redirectAction == removeSlashSuffix {
139+ redirect (w , r , session .prefixReqPath [:len (session .prefixReqPath )- 1 ], h .autoDirSlash )
140140 return
141141 }
142142
143143 if data .CanCors {
144144 cors (w )
145145 }
146146
147- header (w , data . Headers )
147+ header (w , session . headers )
148148
149149 if data .IsMutate {
150- h .mutate (w , r , data )
150+ h .mutate (w , r , session , data )
151151 return
152152 }
153153
154154 // archive
155155 if len (r .URL .RawQuery ) >= 3 {
156156 switch r .URL .RawQuery [:3 ] {
157157 case "tar" :
158- h .tar (w , r , data )
158+ h .tar (w , r , session , data )
159159 return
160160 case "tgz" :
161- h .tgz (w , r , data )
161+ h .tgz (w , r , session , data )
162162 return
163163 case "zip" :
164- h .zip (w , r , data )
164+ h .zip (w , r , session , data )
165165 return
166166 }
167167 }
168168 }
169169
170- if h .applyMiddlewares (h .postMiddlewares , w , r , data , fsPath ) {
170+ if h .applyMiddlewares (h .postMiddlewares , w , r , session , data ) {
171171 return
172172 }
173173
174174 // final process
175- if data .wantJson {
175+ if session .wantJson {
176176 h .json (w , r , data )
177- } else if shouldServeAsContent (data . File , data .Item ) {
178- h .content (w , r , data )
177+ } else if shouldServeAsContent (session . file , data .Item ) {
178+ h .content (w , r , session , data )
179179 } else {
180180 h .page (w , r , data )
181181 }
0 commit comments