handler

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2025 License: Apache-2.0 Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 Body

type Body struct {
	Json map[string]interface{} `param:"<in:body>"`
}

func (*Body) Serve

func (b *Body) Serve(ctx *faygo.Context) error

type Param

type Param struct {
	Id           int                   `param:"<in:path> <required> <desc:ID> <range: 0:10>"`
	Title        string                `param:"<in:query> <nonzero>"`
	Num          float32               `param:"<in:formData> <required> <name:n> <range: 0.1:10> <err: formData param 'n' must be number in 0.1~10>"`
	Paragraph    []string              `param:"<in:formData> <name:p> <len: 1:20> <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>"`
}

func (*Param) Doc

func (p *Param) Doc() faygo.Doc

Doc returns the API's note, result or parameters information.

func (*Param) Serve

func (p *Param) Serve(ctx *faygo.Context) error

Implement the handler interface

type Render

type Render struct {
	Title      string `param:"<in:query> <nonzero>"`
	Paragraph  string `param:"<in:query> <name:p> <len: 1:10> <regexp: ^[\\w]*$>"`
	TestHeader string `param:"<in:header><name:Test-Header> <required><test header>"`
}

func (*Render) Serve

func (r *Render) Serve(ctx *faygo.Context) error
type Search int

func (Search) Doc

func (Search) Doc() faygo.Doc

func (Search) Serve

func (Search) Serve(ctx *faygo.Context) error

Source Files

  • body.go
  • param.go
  • proxy.go
  • render.go
  • websocket.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL