zephyr

package module
v0.0.0-...-8986fd3 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: MIT Imports: 17 Imported by: 0

README

zephyr

go web framwork

Documentation

Overview

Package zephyr Create at 2021-01-19 14:41

Package zephyr Create at 2021-01-19 18:22

Package zephyr Create at 2021-01-19 14:04

Package zephyr Create at 2021-01-19 13:48

Package zephyr Create at 2021-01-19 13:48

Index

Constants

View Source
const (
	// GET http GET method.
	GET = "GET"
	// POST http POST method.
	POST = "POST"
	// PUT http PUT method.
	PUT = "PUT"
	// DELETE http DELETE method.
	DELETE = "DELETE"
	// HEAD http HEAD method.
	HEAD = "HEAD"
	// OPTIONS http OPTIONS method.
	OPTIONS = "OPTIONS"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	URL             string                                       // 请求的URL,支持正则表达式
	Method          []string                                     // 支持的请求方法
	Filter          []Filter                                     // 过滤器
	Handler         func(w http.ResponseWriter, r *http.Request) // 处理请求的方法
	PreHandler      preHandlerFunc
	AfterCompletion afterCompletionFunc
	Wrapper         wrapperFuc
}

Action request mapping

type Filter

type Filter struct {
	Trials TrialItem
	Fit    Fit
	Err    func(w *http.ResponseWriter)
}

Filter 过滤器.

type Fit

type Fit interface {
	DoFilter(request *Request, prerequisite TrialItem) (bool, error)
}

Fit doFilter

type Profile

type Profile struct {
	Name      string // Application name
	Version   string // Application version
	BuildTime string // Compilation date
	GoVersion string // Golang version
	Mode      string // Deployment mode
	URL       string // URL
	Desc      string // Description.
}

Profile 项目信息

func NewProfile

func NewProfile(url, version, goVersion, buildTime, mode string) *Profile

NewProfile profile

func (*Profile) Description

func (p *Profile) Description() string

Description profile desc

func (*Profile) Handler

func (p *Profile) Handler(w http.ResponseWriter, r *http.Request)

Handler url handler

type Request

type Request struct {
	Query  url.Values
	Body   []byte
	Header http.Header
	Method string
}

Request req data

type Resp

type Resp struct {
	Code int
	Msg  []byte
}

Resp response body

type TrialItem

type TrialItem struct {
	Condition map[string]string
	Rules     []string
}

TrialItem 预处理选项

type Zephyr

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

Zephyr web framework

func NewZephyr

func NewZephyr(logger *logrus.Logger) *Zephyr

NewZephyr new Zephyr obj.

func (*Zephyr) AddFilter

func (z *Zephyr) AddFilter(filter Filter) *Zephyr

AddFilter add filter.

func (*Zephyr) AddHandler

func (z *Zephyr) AddHandler(r Action)

AddHandler add handler.

func (*Zephyr) GetLogger

func (z *Zephyr) GetLogger() *logrus.Logger

GetLogger get logger

func (*Zephyr) ServeHTTP

func (z *Zephyr) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is the HTTP Entry point for a Martini instance. Useful if you want to control your own HTTP server.

func (*Zephyr) SetAfterCompletion

func (z *Zephyr) SetAfterCompletion(afterCompletion afterCompletionFunc)

SetAfterCompletion set afterCompletion.

func (*Zephyr) SetCros

func (z *Zephyr) SetCros(cros bool)

SetCros enable or disable cros

func (*Zephyr) SetErrResp

func (z *Zephyr) SetErrResp(resp Resp)

SetErrResp set default err response.

func (*Zephyr) SetPreHandler

func (z *Zephyr) SetPreHandler(preHandler preHandlerFunc)

SetPreHandler set preHandler.

func (*Zephyr) SetProfile

func (z *Zephyr) SetProfile(profile *Profile)

SetProfile set service profile

func (*Zephyr) SetWrapper

func (z *Zephyr) SetWrapper(wrapper wrapperFuc)

SetWrapper set ResponseWriter wrapper

Directories

Path Synopsis
Package example Create at 2021-01-19 18:20
Package example Create at 2021-01-19 18:20

Jump to

Keyboard shortcuts

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