cork

package module
v0.0.0-...-9696987 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2020 License: MIT Imports: 11 Imported by: 0

README

Old-Cork

Go Web API Framework

Documentation

Index

Constants

View Source
const (
	GET    string = "GET"
	POST   string = "POST"
	PATCH  string = "PATCH"
	DELETE string = "DELETE"
	PUT    string = "PUT"
)
View Source
const ROOT_ROUTE = "/"

Variables

View Source
var ErrorHandler = func(message *Message) {

	message.ReturnStatus(message.Error.Status)
}

Functions

func NewDefaultRouter

func NewDefaultRouter() *defaultRouter

Types

type Action

type Action interface {
	Create(action interface{}) Handler
}

type Cork

type Cork struct {
	Routes   func(r Routes)
	Services *Services
	Error    Handler
	// contains filtered or unexported fields
}

func Pop

func Pop() *Cork

func (*Cork) Handler

func (c *Cork) Handler() http.Handler

type DefaultAction

type DefaultAction struct{}

func (DefaultAction) Create

func (a DefaultAction) Create(action interface{}) Handler

type Dispatcher

type Dispatcher interface {
	http.Handler
	SettingsHandler
}

type Error

type Error struct {
	Status int
	// contains filtered or unexported fields
}

func NewError

func NewError(err error, status int) *Error

type Handler

type Handler interface {
	Handle(*Message)
}

type HandlerExpression

type HandlerExpression interface {
	Handle(Handler) HandlerWithExpression
	HandleFunc(func(*Message)) HandlerWithExpression
}

type HandlerFunc

type HandlerFunc func(*Message)

func (HandlerFunc) Handle

func (h HandlerFunc) Handle(message *Message)

type HandlerWithExpression

type HandlerWithExpression interface {
	HandlerExpression
	WithExpression
}

type Message

type Message struct {
	*http.Request

	Response http.ResponseWriter
	Route    *Route
	Context  interface{}
	Params   map[string]string
	Error    *Error
	Settings *Cork
	// contains filtered or unexported fields
}

func (*Message) Next

func (m *Message) Next()

func (*Message) Return

func (m *Message) Return(status int, payload interface{})

func (*Message) ReturnError

func (m *Message) ReturnError(status int, err error)

func (*Message) ReturnOK

func (m *Message) ReturnOK(payload interface{})

func (*Message) ReturnServerError

func (m *Message) ReturnServerError(err error)

func (*Message) ReturnStatus

func (m *Message) ReturnStatus(status int)

func (*Message) SetRoute

func (m *Message) SetRoute(route *Route)

type MessageCreator

type MessageCreator interface {
	NewMessage(*http.Request, http.ResponseWriter, *Cork) *Message
}

type Route

type Route struct {
	Template string
	Method   string
	Action   Handler
	Segments []*Segment
	Handlers []Handler
	// contains filtered or unexported fields
}

func NewRoute

func NewRoute(template string, method string) (*Route, error)

type Router

type Router interface {
	Route(method string, url *url.URL) *Route
	SettingsHandler
}

type Routes

type Routes interface {
	Get(template string, action interface{}) HandlerWithExpression
	Forward(prefix string, routes func(r Routes))
}

type Segment

type Segment struct {
	Name     string
	Variable bool
	Value    string
}

type Services

type Services struct {
	Dispatcher     Dispatcher
	Router         Router
	Action         Action
	MessageCreator MessageCreator
}

func NewServices

func NewServices() *Services

type SettingsHandler

type SettingsHandler interface {
	Configure(cork *Cork)
}

type WithExpression

type WithExpression interface {
	WithContext(interface{})
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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