zeta

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: MIT Imports: 8 Imported by: 1

README

Introduce

A framework that helps other major Web frameworks work better.

Feature

Zeta has the following features:

  • less invasive
  • use simple
  • easily plug
  • extensible
  • practice is the sole criterion for testing truth

Usage

The sample of Gin:

package main

import (
	"context"
	"fmt"
	"github.com/gin-gonic/gin"
	"github.com/zeta-io/ginx"
	"github.com/zeta-io/zeta"
)

func list(context context.Context, c1 *context.Context, args struct{
	Name string `json:"name" param:"query,name" validator:"required"`
}) (string, error){
	fmt.Println(args.Name)
	return "hello zeta", nil
}

func main() {
	router := zeta.Router("/api/:version/users")
	router.Get("", list)

	e := zeta.New(router, ginx.New(gin.New())).Run(":8080")
	if e != nil{
		panic(e)
	}
}

More samples.

Driver

  • Ginx: Gin driver for zeta.

Documentation

Overview

Router

* 2 * @Author: Nico 3 * @Date: 2020/11/8 17:53 4

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentType

type ContentType string
const (
	ContentTypePostForm ContentType = "application/x-www-form-urlencoded"
	ContentTypeFormData ContentType = "multipart/form-data"
	ContentTypeJSON     ContentType = "application/json"
	ContentTypeXML      ContentType = "application/xml"
)

type Driver

type Driver interface {
	Option
	Run(addr ...string) error
}

type HandlerFunc

type HandlerFunc interface{}

type JSON

type JSON interface {
	Marshal(v interface{}) ([]byte, error)
	Unmarshal(data []byte, v interface{}) error
}

func DefaultJSON

func DefaultJSON() JSON

type Mapping added in v1.0.4

type Mapping struct {
	// contains filtered or unexported fields
}

func (*Mapping) Method added in v1.0.4

func (m *Mapping) Method() Method

func (*Mapping) Middleware added in v1.0.4

func (m *Mapping) Middleware() []HandlerFunc

func (*Mapping) Url added in v1.0.4

func (m *Mapping) Url() string

type Method

type Method string
const (
	MethodGet     Method = "GET"
	MethodHead    Method = "HEAD"
	MethodPost    Method = "POST"
	MethodPut     Method = "PUT"
	MethodDelete  Method = "DELETE"
	MethodConnect Method = "CONNECT"
	MethodOptions Method = "OPTIONS"
	MethodTrace   Method = "TRACE"
	MethodPatch   Method = "PATCH"
	MethodAny     Method = "ANY"
)

type Option

type Option interface {
	Option(zeta *Zeta)
}

type Serial

type Serial interface {
	Serial(dest interface{}) string
	DeSerial(src interface{}, t reflect.Type) (interface{}, error)
}

func DefaultSerial

func DefaultSerial(jsons ...JSON) Serial

type Validator

type Validator interface {
	Validate(s interface{}) error
}

func DefaultValidator

func DefaultValidator() Validator

type Zeta added in v1.0.2

type Zeta struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New(d Driver, options ...Option) *Zeta

func (*Zeta) Complete added in v1.0.3

func (z *Zeta) Complete()

func (Zeta) Group added in v1.0.4

func (r Zeta) Group(url string, middleware ...HandlerFunc) *group

func (Zeta) Handle added in v1.0.4

func (r Zeta) Handle(method Method, url string, middleware ...HandlerFunc) *router

func (Zeta) Mappings added in v1.0.4

func (r Zeta) Mappings() []Mapping

func (Zeta) Middleware added in v1.0.4

func (r Zeta) Middleware() []HandlerFunc

func (Zeta) Option added in v1.0.4

func (r Zeta) Option(z *Zeta)

func (*Zeta) Options added in v1.0.4

func (z *Zeta) Options(options ...Option) *Zeta

func (*Zeta) Run added in v1.0.2

func (z *Zeta) Run(addr ...string) error

func (Zeta) Use added in v1.0.2

func (r Zeta) Use(middleware ...HandlerFunc) *router

Jump to

Keyboard shortcuts

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