router

package
v0.0.0-...-1568502 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2020 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthorizationMiddleware

func AuthorizationMiddleware(c *gin.Context)

Authenticates the request token against the given permission string, ensuring that if it is a server permission, the token has control over that server. If it is a global token, this will ensure that the request is using a properly signed global token.

func Configure

func Configure() *gin.Engine

Configures the routing infrastructure for this daemon instance.

func GetServer

func GetServer(uuid string) *server.Server

Helper function to fetch a server out of the servers collection stored in memory.

func ServerExists

func ServerExists(c *gin.Context)

Ensure that the requested server exists in this setup. Returns a 404 if we cannot locate it.

func SetAccessControlHeaders

func SetAccessControlHeaders(c *gin.Context)

Set the access request control headers on all of the requests.

Types

type RequestError

type RequestError struct {
	Err     error
	Uuid    string
	Message string
	// contains filtered or unexported fields
}

func TrackedError

func TrackedError(err error) *RequestError

Generates a new tracked error, which simply tracks the specific error that is being passed in, and also assigned a UUID to the error so that it can be cross referenced in the logs.

func TrackedServerError

func TrackedServerError(err error, s *server.Server) *RequestError

Same as TrackedError, except this will also attach the server instance that generated this server for the purposes of logging.

func (*RequestError) AbortFilesystemError

func (e *RequestError) AbortFilesystemError(c *gin.Context)

Handle specific filesystem errors for a server.

func (*RequestError) AbortWithServerError

func (e *RequestError) AbortWithServerError(c *gin.Context)

Helper function to just abort with an internal server error. This is generally the response from most errors encountered by the API.

func (*RequestError) AbortWithStatus

func (e *RequestError) AbortWithStatus(status int, c *gin.Context)

Aborts the request with the given status code, and responds with the error. This will also include the error UUID in the output so that the user can report that and link the response to a specific error in the logs.

func (*RequestError) Error

func (e *RequestError) Error() string

Format the error to a string and include the UUID.

func (*RequestError) SetMessage

func (e *RequestError) SetMessage(msg string) *RequestError

Sets the output message to display to the user in the error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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