mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
修改http返回
This commit is contained in:
@@ -167,7 +167,6 @@ func (slf *HttpSession) DelHeader(key string) {
|
||||
slf.r.Header.Del(key)
|
||||
}
|
||||
|
||||
|
||||
func (slf *HttpSession) WriteStatusCode(statusCode int){
|
||||
slf.statusCode = statusCode
|
||||
}
|
||||
@@ -176,15 +175,18 @@ func (slf *HttpSession) Write(msg []byte) {
|
||||
slf.msg = msg
|
||||
}
|
||||
|
||||
func (slf *HttpSession) WriteJson(msgJson interface{}) error {
|
||||
func (slf *HttpSession) WriteJsonDone(statusCode int,msgJson interface{}) error {
|
||||
msg, err := json.Marshal(msgJson)
|
||||
if err == nil {
|
||||
slf.Write(msg)
|
||||
}
|
||||
|
||||
slf.Done()
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (slf *HttpSession) flush() {
|
||||
slf.w.WriteHeader(slf.statusCode)
|
||||
if slf.msg!=nil {
|
||||
@@ -192,7 +194,7 @@ func (slf *HttpSession) flush() {
|
||||
}
|
||||
}
|
||||
|
||||
func (slf *HttpSession) done(){
|
||||
func (slf *HttpSession) Done(){
|
||||
slf.sessionDone <- slf
|
||||
}
|
||||
|
||||
@@ -259,7 +261,7 @@ func (slf *HttpRouter) Router(session *HttpSession){
|
||||
if slf.httpFiltrateList!=nil {
|
||||
for _,fun := range slf.httpFiltrateList{
|
||||
if fun(session) == false {
|
||||
session.done()
|
||||
//session.done()
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -278,7 +280,7 @@ func (slf *HttpRouter) Router(session *HttpSession){
|
||||
}
|
||||
|
||||
v.httpHandle(session)
|
||||
session.done()
|
||||
//session.done()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -286,13 +288,13 @@ func (slf *HttpRouter) Router(session *HttpSession){
|
||||
idx := strings.Index(urlPath, k)
|
||||
if idx != -1 {
|
||||
session.fileData = v
|
||||
session.done()
|
||||
session.Done()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
session.WriteStatusCode(http.StatusNotFound)
|
||||
session.done()
|
||||
session.Done()
|
||||
}
|
||||
|
||||
func (slf *HttpService) SetHttpRouter(httpRouter IHttpRouter) {
|
||||
|
||||
Reference in New Issue
Block a user