router

package
v0.0.0-...-ce8dd9f Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2021 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure(m *server.Manager, client remote.Client) *gin.Engine

Configure configures the routing infrastructure for this daemon instance.

func DownloadFile

func DownloadFile(filepath string, url string) (string, error)

Download file from URL

func ExtractServer

func ExtractServer(c *gin.Context) *server.Server

ExtractServer returns the server instance from the gin context. If there is no server set in the context (e.g. calling from a controller not protected by ServerExists) this function will panic.

This function is deprecated. Use middleware.ExtractServer.

func WithError

func WithError(c *gin.Context, err error) error

Attaches an error to the gin.Context object for the request and ensures that it has a proper stacktrace associated with it when doing so.

If you just call c.Error(err) without using this function you'll likely end up with an error that has no annotated stack on it.

Types

type RequestError

type RequestError struct {
	// contains filtered or unexported fields
}

func NewServerError

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

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

func NewTrackedError

func NewTrackedError(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 (*RequestError) Abort

func (e *RequestError) Abort(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) AbortFilesystemError

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

Handle specific filesystem errors for a server.

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