rpc/adapter/fasthttp/server_handlers.go

45 lines
851 B
Go
Raw Normal View History

2017-11-08 06:35:27 +00:00
package fasthttp
import (
"io"
"github.com/valyala/fasthttp"
"git.loafle.net/commons_go/rpc/server"
)
type ServerHandlers struct {
server.ServerHandlers
}
func (sh *ServerHandlers) OnPreRead(r io.Reader) {
// no op
}
func (sh *ServerHandlers) OnPostRead(r io.Reader) {
// no op
}
func (sh *ServerHandlers) OnPreWriteResult(w io.Writer, result interface{}) {
ctx := w.(*fasthttp.RequestCtx)
ctx.Response.Header.Set("x-content-type-options", "nosniff")
ctx.SetContentType("application/json; charset=utf-8")
}
func (sh *ServerHandlers) OnPostWriteResult(w io.Writer, result interface{}) {
// no op
}
func (sh *ServerHandlers) OnPreWriteError(w io.Writer, err error) {
// no op
}
func (sh *ServerHandlers) OnPostWriteError(w io.Writer, err error) {
// no op
}
func (sh *ServerHandlers) Validate() {
sh.ServerHandlers.Validate()
}