Documentation ¶
Overview ¶
Package view provides a simple way to create HTTP handlers that implement the http.Handler interface.
Index ¶
- Constants
- func Generic(authorizer auth.Authorizer) func(next http.Handler) http.Handler
- type DataStructInterface
- type GenericFunc
- type GenericResponseWriter
- func (w *GenericResponseWriter) BuildWebAnnotation(ctx context.Context, msg proto.Message) error
- func (w *GenericResponseWriter) SetDataStructFlag(ok bool)
- func (w *GenericResponseWriter) SetError(err error)
- func (w *GenericResponseWriter) SetWriterAttrs(ctx context.Context, msg proto.Message) error
- func (w *GenericResponseWriter) Write(data []byte) (int, error)
Constants ¶
View Source
const ( // BK_APIv1_CODE_KEY 蓝鲸规范返回的 code key BK_APIv1_CODE_KEY = "code" // BK_APIv1_CODE_OK_VALUE 蓝鲸规范返回正常请求的 code value BK_APIv1_CODE_OK_VALUE = 0 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DataStructInterface ¶
type DataStructInterface interface {
IsDataStruct() bool
}
DataStructInterface 判断是否已经包含 data 结构体实现, 处理 structpb.Struct 问题
type GenericFunc ¶
GenericFunc View函数类型, 使用view.GenericFunc(customHandler)
func (GenericFunc) ServeHTTP ¶
func (h GenericFunc) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP handler 函数实现
type GenericResponseWriter ¶
type GenericResponseWriter struct { http.ResponseWriter // contains filtered or unexported fields }
GenericResponseWriter 自定义Write,自动补充 data 和 web_annotations 数据
func NewGenericResponseWriter ¶
func NewGenericResponseWriter(w http.ResponseWriter, authorizer auth.Authorizer) *GenericResponseWriter
NewGenericResponseWriter GenericResponseWriter初始化
func (*GenericResponseWriter) BuildWebAnnotation ¶
BuildWebAnnotation 动态执行 webannotions 函数
func (*GenericResponseWriter) SetDataStructFlag ¶
func (w *GenericResponseWriter) SetDataStructFlag(ok bool)
SetDataStructFlag 设置是否是 DataStruct 类型
func (*GenericResponseWriter) SetError ¶
func (w *GenericResponseWriter) SetError(err error)
SetError 设置错误请求
func (*GenericResponseWriter) SetWriterAttrs ¶
SetWriterAttrs set attributes of the writer
Directories ¶
Path | Synopsis |
---|---|
Package modifier is the interface used to modify response
|
Package modifier is the interface used to modify response |
Package webannotation webannotation
|
Package webannotation webannotation |
Click to show internal directories.
Click to hide internal directories.