apirest

package
v0.0.0-...-09cb928 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2017 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap(k *dislet.Kernel)

func GenerateToken

func GenerateToken(k *dislet.Kernel, user *usermngr.User) (string, error)

func GetBody

func GetBody(protoMessage proto.Message, r *http.Request) error

func GetUser

func GetUser(k *dislet.Kernel, r *http.Request) (*usermngr.User, error)

func NewApiRest

func NewApiRest(k *dislet.Kernel, port int) *mux.Router

func SendTask

func SendTask(kernel *dislet.Kernel, task *tasks.Signature) (proto.Message, error)

Shortcut to launch a task

func TaskResponseHandler

func TaskResponseHandler(result *tasks.TaskState) proto.Message

Format task information. Used everytime your controller runs a task

func Validate

func Validate(data interface{}, validatorI interface{}) (*interface{}, error)

Validate input data against a model

func VerifyRequest

func VerifyRequest(k *dislet.Kernel, r *http.Request) (jwt.MapClaims, error)

Types

type Config

type Config struct {
	Port int
	Hmac string
}

type Error

type Error interface {
	error
	Status() int
}

Error represents a handler error. It provides methods for a HTTP status code and embeds the built-in error interface.

type Handler

type Handler struct {
	*dislet.Kernel
	H func(k *dislet.Kernel, w http.ResponseWriter, r *http.Request) (proto.Message, error)
}

func (Handler) ServeHTTP

func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP allows our Handler type to satisfy http.Handler.

type MessageHandler

type MessageHandler struct {
	*dislet.Kernel
	H       func(k *dislet.Kernel, w http.ResponseWriter, r *http.Request, message proto.Message) (proto.Message, error)
	Message proto.Message
}

func (MessageHandler) ServeHTTP

func (h MessageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP allows our Handler type to satisfy http.Handler.

type SecureHandler

type SecureHandler struct {
	*dislet.Kernel
	H func(k *dislet.Kernel, w http.ResponseWriter, r *http.Request, user *usermngr.User) (proto.Message, error)
}

func (SecureHandler) ServeHTTP

func (h SecureHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP allows our Handler type to satisfy http.Handler.

type StatusError

type StatusError struct {
	Code int
	Err  error
}

StatusError represents an error with an associated HTTP status code.

func (StatusError) Error

func (se StatusError) Error() string

Allows StatusError to satisfy the error interface.

func (StatusError) Status

func (se StatusError) Status() int

Returns our HTTP status code.

Directories

Path Synopsis
Package protomodel is a generated protocol buffer package.
Package protomodel is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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