contracts

package
v0.0.0-...-f513fc6 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenable

type Authenable interface {
	UserID() string
	SetUserID(string)
}

Authenable is authentication manager.

type Cachable

type Cachable interface {
	Get(id string) interface{}
	Set(id string, value interface{}, ttl time.Duration)
	Del(id string)
	Push(id string, value interface{})
	Pop(id string) interface{}
	Flush()
	GC()
}

Cachable represents Cachable specification.

type Callable

type Callable func(Context) (int, interface{})

Callable use to handle incoming requests.

type Context

type Context interface {
	Request() Request
	Response() Response
	Auth() Authenable
	URL(string, map[string]string) string
	Cache() Cachable
	Session() Session
}

Context represents incoming connection.

type Mango

type Mango interface {
	Any(string, Callable, ...ThenableFunc)
	Get(string, Callable, ...ThenableFunc)
	Post(string, Callable, ...ThenableFunc)
	Put(string, Callable, ...ThenableFunc)
	Delete(string, Callable, ...ThenableFunc)
	Group(string, func(Router), ...ThenableFunc)
	Use(ThenableFunc)
	SetDefaultRoute(Callable)
	SetCachable(Cachable)
	Start(string)
	StartTLS(string, string, string)
	StartAutoTLS(string, autocert.Cache, ...string)
	ServeHTTP(http.ResponseWriter, *http.Request)
	On(event string, fn func())
}

Mango interface of mango micro framework.

type Request

type Request interface {
	Parent() *http.Request
	IP() string
	File(string) (UploadedFile, error)
	Form(string) string
	Query(string) string
	Arg(string) string
	Input(string) string
	JSON(interface{}) error
	IsTLS() bool
	Header() http.Header
	Method() string
	URI() string
	URL() *url.URL
	Host() string
	SetArgs(map[string]string)
	Args() map[string]string
}

Request represents incoming data from client.

type Response

type Response interface {
	Parent() http.ResponseWriter
	Write([]byte) (int, error)
	WriteString(string) (int, error)
	WriteJSON(interface{}) error
	Header() http.Header
	Clear()
	Size() int
	Status() int
	SetStatus(int)
	SetCookie(*http.Cookie)
	DelCookie(string)
	Redirect(int, string) (int, interface{})
	Buffered() []byte
	Send() error
}

Response is interface of data will be sent to client.

type Route

type Route interface {
	Method() string
	Path() string
	SetPath(string)
	Pathable() *regexp.Regexp
	Callable() Callable
	ThenStack() []ThenableFunc
	IsStatic() bool
}

Route is part of Router.

type Router

type Router interface {
	Any(string, Callable, ...ThenableFunc)
	Get(string, Callable, ...ThenableFunc)
	Post(string, Callable, ...ThenableFunc)
	Put(string, Callable, ...ThenableFunc)
	Delete(string, Callable, ...ThenableFunc)
	Group(string, func(Router), ...ThenableFunc)
	Use(...ThenableFunc)
	Prefixes() []string
	ThenableStack() []ThenableFunc
	SetThenableStack(...ThenableFunc)
	ToMatch(Request) (Route, map[string]string)
	SetDefaultRoute(Callable)
}

Router interface.

type Session

type Session interface {
	Set(string, interface{})
	Get(string) (interface{}, bool)
}

Session interface.

type ThenableContext

type ThenableContext interface {
	Context
	Next()
}

ThenableContext is a context for thenable fucntion.

type ThenableFunc

type ThenableFunc func(ThenableContext)

ThenableFunc uses as a thenable function as a middleware.

type UploadedFile

type UploadedFile interface {
	Header() textproto.MIMEHeader
	Filename() string
	Size() int64
	StoreAs(path string, name string) (string, error)
	Store(path string) (string, error)
}

UploadedFile is interface of uploaded files handler.

Jump to

Keyboard shortcuts

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