routing

package
v0.0.0-...-0b73d59 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2022 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRoute

func AddRoute(name string, routes map[string]Method)

func DoTick

func DoTick()

func HandleAPI

func HandleAPI(writer http.ResponseWriter, request *http.Request)

func InitRouter

func InitRouter()

Types

type HTTPMethod

type HTTPMethod interface {
	Method
	Process(user *elling.User, params *url.Values) *HTTPResponse
}

type HTTPResponse

type HTTPResponse struct {
	Response
	Code int
}

func GenBadRequestResponse

func GenBadRequestResponse(message string) *HTTPResponse

func GenForbiddenResponse

func GenForbiddenResponse(message string) *HTTPResponse

func GenInternalServerError

func GenInternalServerError(message string) *HTTPResponse

func GenSuccessResponse

func GenSuccessResponse(answer interface{}) *HTTPResponse

func GenTooManyRequestsResponse

func GenTooManyRequestsResponse(message string) *HTTPResponse

func GenUnauthorizedResponse

func GenUnauthorizedResponse(message string) *HTTPResponse

func (*HTTPResponse) Write

func (r *HTTPResponse) Write(writer http.ResponseWriter)

type Method

type Method interface {
	IsPublic() bool
	GetLimit() int
	GetType() MethodType
}

type MethodType

type MethodType int
const (
	Http MethodType = iota
	Socket
)

type Response

type Response struct {
	Success bool        `json:"success,omitempty"`
	Message string      `json:"message,omitempty"`
	Answer  interface{} `json:"answer,omitempty"`
}

type SocketMethod

type SocketMethod interface {
	Method
	CanRegister(params *url.Values) *HTTPResponse
	Register(conn *websocket.Conn, user *elling.User)
}

Jump to

Keyboard shortcuts

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