Documentation
¶
Index ¶
- Variables
- func IsNotFound(err error) bool
- func IsValidColor(name ColorName) (isValid bool, err error)
- func IsValidUUID(uuid string) bool
- type APIResponse
- type APIResponseError
- type APIResponseError400
- type APIResponseError404
- type APIResponseError409
- type APIResponseError500
- type Color
- type ColorName
- type Enabled
- type Label
- type LabelID
- type LabelRequest
- type Link
- type LinkID
- type LinkRequest
- type Model
- type Namespace
- type NamespaceRequest
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Colors = map[ColorName]Color{ ColorRed: { Hex: "#EF4444", }, ColorOrange: { Hex: "#F97316", }, ColorYellow: { Hex: "#FCD34D", }, ColorGreen: { Hex: "#10B981", }, ColorBlue: { Hex: "#3B82F6", }, ColorIndigo: { Hex: "#6366F1", }, ColorViolet: { Hex: "#8B5CF6", }, ColorGray: { Hex: "#6B7280", }, ColorBrown: { Hex: "#B45309", }, ColorPink: { Hex: "#EC4899", }, ColorPurple: { Hex: "#9333EA", }, } ColorsName = func() (cN []string) { for colorName := range Colors { cN = append(cN, colorName.String()) } return cN } )
Functions ¶
func IsNotFound ¶
func IsValidColor ¶
IsValidColor checks if the color name is valid.
func IsValidUUID ¶
IsValidUUID checks if the given string is a valid UUID.
Types ¶
type APIResponse ¶
type APIResponse[T any] struct { ID string `json:"id" example:"05aebb0d-0169-4bde-bc6d-8662e4680108"` // ID is the unique identifier of the request Method string `json:"method" example:"link.list"` // Method is the text representation of the request (link.get) Params map[string]string `json:"params" example:"param:value,param2:value2"` // Params is the parameters of the request Data T `json:"data" swaggerignore:"true"` // Data is the data of the request }
type APIResponseError ¶
type APIResponseError[I any] struct { ID string `json:"id" example:"05aebb0d-0169-4bde-bc6d-8662e4680108"` // ID is the unique identifier of the request Method string `json:"method" example:"link.list"` // Method is the text representation of the request (link.get) Params map[string]string `json:"params" example:"param:value,param2:value2"` // Params is the parameters of the request Error I `json:"error" swaggerignore:"true"` // Error is the error of the request }
type APIResponseError400 ¶
type APIResponseError404 ¶
type APIResponseError409 ¶
type APIResponseError409 struct {
Code int `json:"code" example:"409"`
Message string `json:"message" example:"Conflict"`
}
409 Conflict.
type APIResponseError500 ¶
type Color ¶
type Color struct {
// Hex is the hex code of the color
Hex string `json:"hex"`
}
Color is the model for the color.
type ColorName ¶
type ColorName string
Name is the name of the color.
const ( ColorDefault = ColorGray ColorRed ColorName = "red" ColorOrange ColorName = "orange" ColorYellow ColorName = "yellow" ColorGreen ColorName = "green" ColorBlue ColorName = "blue" ColorIndigo ColorName = "indigo" ColorViolet ColorName = "violet" ColorGray ColorName = "gray" ColorBrown ColorName = "brown" ColorPink ColorName = "pink" ColorPurple ColorName = "purple" )
type Label ¶
type Label struct {
// ID is the unique identifier of the label
ID LabelID `json:"id,omitempty" example:"f7c5c4a0-6a1f-4d4b-8a9f-5b5d6d9b8c4d"`
LabelRequest
}
Label is the model for the label.
func (Label) MarshalJSON ¶
MarshalJSON marshal the JSON value.
func (*Label) UnmarshalJSON ¶
UnmarshalJSON unmarshals the JSON value into a LabelID.
type LabelRequest ¶
type Link ¶
type Link struct {
// ID is the unique identifier of the link in the database
ID LinkID `json:"id" example:"84214e93-437e-434d-96c2-22c3a63b3c67"`
// CreatedAt is the time the link was created - RFC3339
CreatedAt string `json:"createdAt" example:"2021-07-04T15:04:05.999999999Z"`
// UpdatedAt is the time the link was last modified - RFC3339
UpdatedAt string `json:"lastModified" example:"2021-07-04T15:04:05.999999999Z"`
// Namespace is the group the link belongs to
NameSpace string `json:"namespace" example:"prod"`
LinkRequest
}
Link is the model for the shortened link.
func (*Link) MarshalJSON ¶
MarshalJSON marshal the JSON value.
func (*Link) UnmarshalJSON ¶
UnmarshalJSON unmarshals the JSON value into a LinkID.
type LinkRequest ¶
type LinkRequest struct {
// Name is the name of the link
Name string `json:"name" example:"example" validate:"required"`
// SourcePath is the path of the link
SourcePath string `json:"sourcePath" example:"/example" validate:"required"`
// TargetURL is the original URL
TargetURL string `json:"targetUrl" example:"https://example.com" validate:"required"`
// Labels is the list of labels associated with the link
Labels []LabelID `json:"labels,omitempty" example:"a54abdd8-776c-4982-bba7-34caa58596c4,fcb0726f-9701-492c-afe7-aa7121afc9cf"`
// Enabled is the status of the link
Enabled Enabled `json:"enabled" example:"true" validate:"required"`
}
LinkRequest is the model for the link request.
type Namespace ¶
type Namespace struct {
NamespaceRequest
// Links is the list of links associated with the namespace
Links []Link `json:"links"`
// Enabled is the status of the namespace
Enabled Enabled `json:"enabled"`
}
Namespace is the model for the namespace.
func (*Namespace) MarshalJSON ¶
MarshalJSON marshal the JSON value.
func (*Namespace) UnmarshalJSON ¶
UnmarshalJSON unmarshals the JSON value into a NamespaceID.
type NamespaceRequest ¶
type NamespaceRequest struct {
// Name is the name of the namespace
Name string `json:"name"`
}
func (*NamespaceRequest) Validate ¶
func (g *NamespaceRequest) Validate() error
Validate validates the namespace request.
Click to show internal directories.
Click to hide internal directories.