rest

package
v0.0.0-...-2119b44 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MPL-2.0 Imports: 23 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SESSION_KEY = "ukama_session"

Functions

func GetDataFromURL

func GetDataFromURL(url string) ([]byte, error)

HTTP req to GET data from URL, Returns byte array

func GetNodeIdFromPath

func GetNodeIdFromPath(c *gin.Context, nodeIdKey string) (id ukama.NodeID, isValid bool)

GetNodeIdFromPath extracts nodeId from url parameter with nodeIdKey name and returns the value as NodeId object in case of parsing error or missing parameter it will use context to return error message and http.StatusBadRequest code

func GetUuidFromPath

func GetUuidFromPath(c *gin.Context, uuidKey string) (id uuid.UUID, isValid bool)

func NewFizzRouter

func NewFizzRouter(httpConfig *HttpConfig, srvName string, srvVersion string, isDebug bool, redirectUrl string) *fizz.Fizz

func SendErrorResponseFromGet

func SendErrorResponseFromGet(c *gin.Context, entityType string, err error)

func ThrowError

func ThrowError(c *gin.Context, status int, message string, details string, err error)

Types

type ErrorMessage

type ErrorMessage struct {
	Message string `json:"message"`
	Details string `json:"details,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Err string `json:"error,omitempty"`
}

func (ErrorResponse) Error

func (e ErrorResponse) Error() string

type ExtJson

type ExtJson struct {
	Data   interface{}
	Indent bool
}

func (ExtJson) Render

func (r ExtJson) Render(w http.ResponseWriter) (err error)

Render (JSON) writes data with custom ContentType.

func (ExtJson) WriteContentType

func (r ExtJson) WriteContentType(w http.ResponseWriter)

writeContentType (JSON) writes JSON ContentType.

type HttpConfig

type HttpConfig struct {
	Port int         `default:"8080"`
	Cors cors.Config `default:"{\"AllowOrigins\": [\"http://localhost\", \"https://localhost\", \"*\"]}"`
}

func DefaultHTTPConfig

func DefaultHTTPConfig() HttpConfig

Use this if you don't use github.com/num30/config

type HttpError

type HttpError struct {
	HttpCode int
	Message  string
}

func (HttpError) Error

func (g HttpError) Error() string

type PingResponse

type PingResponse struct {
	Message string `json:"message"`
	Service string `json:"service"`
}

type RestClient

type RestClient struct {
	C   *resty.Client
	URL *url.URL
}

func NewRestClient

func NewRestClient(path string, debug bool) (*RestClient, error)

func NewRestClientWithClient

func NewRestClientWithClient(hc *http.Client, path string, debug bool) (*RestClient, error)

func NewRestyClient

func NewRestyClient(url *url.URL, debug bool) *RestClient

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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