Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Websocket = faygo.WrapDoc(func(ctx *faygo.Context) error { var upgrader = websocket.Upgrader{} conn, err := upgrader.FayUpgrade(ctx, nil) if err != nil { return err } defer conn.Close() for { var req interface{} if err := conn.ReadJSON(&req); err != nil { ctx.Log().Warning("read:", err) return nil } ctx.Log().Info("req:", req) if err := conn.WriteJSON(map[string]string{"server_time": time.Now().String()}); err != nil { ctx.Log().Warning("write:", err) return nil } } }, "websocket example", map[string]string{"server_time": time.Now().String()}, )
Functions ¶
func Index ¶
func Index() faygo.HandlerFunc
func WebsocketPage ¶
func WebsocketPage() faygo.HandlerFunc
Types ¶
type Param ¶
type Param struct { Id int `param:"<in:path> <required> <desc:ID> <range: 0:10>"` Num float32 `param:"<in:query> <required> <name:n> <range: 0.1:10> <err: query param 'n' must be number in 0.1~10>"` Title string `param:"<in:query> <nonzero>"` Paragraph []string `param:"<in:query> <name:p> <len: 1:10> <regexp: ^[\\w]*$>"` Picture *multipart.FileHeader `param:"<in:formData> <name:pic> <maxmb:30>"` Cookie *http.Cookie `param:"<in:cookie> <name:faygo>"` CookieString string `param:"<in:cookie> <name:faygo>"` }
Click to show internal directories.
Click to hide internal directories.