commonRestful

package
v0.0.0-...-5211220 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2016 License: Apache-2.0 Imports: 8 Imported by: 9

Documentation

Index

Constants

View Source
const (
	// HTTPGetStr : HTTP GET token
	HTTPGetStr = "GET"
	// HTTPPostStr : HTTP POST token
	HTTPPostStr = "POST"
	// HTTPPutStr : HTTP PUT token
	HTTPPutStr = "PUT"
	// HTTPDeleteStr : HTTP DELETE token
	HTTPDeleteStr = "DELETE"
	// HTTPPatchStr : HTTP PATCH token
	HTTPPatchStr = "PATCH"

	// GetMessageStr : string to get parameters from the HTP request
	GetMessageStr = "get-data"

	// SetCookieStr : token use to set the cookie
	SetCookieStr = "Set-Cookie"
	// AccessToken : token use to set the AccessToken
	AccessToken = "AccessToken"
	// NoMessageStr : define the empty message
	NoMessageStr = ""

	// VersionPath : define the version path
	VersionPath = "/version"
)

Variables

View Source
var (
	// ServicePathPrefix : prefix to be use by the RESTFul API
	ServicePathPrefix = "/forewind/app"
	// Version : the current RESTFul version
	Version = "/v1"

	// EmptyStr : the defined EmptyStr
	EmptyStr = StringMessage{""}
)

Functions

func ConvertCommandToRequest

func ConvertCommandToRequest(cmd string) string

ConvertCommandToRequest : Remove all the {} from the command string so it could be used for request

func GetPropertyData

func GetPropertyData(userName string, propertyName string, usersList *en.EntityManager) (interface{}, error)

GetPropertyData : extract the property data from the relevant module

func GetResponse

func GetResponse(response *http.Response, err error) (int, string, error)

GetResponse : parse the http response

func HTTPDataMethod

func HTTPDataMethod(method string, url string, data string) (int, string, error)

HTTPDataMethod : extract the http data method and atach the cookie

func RemoveSpaces

func RemoveSpaces(inStr string) string

RemoveSpaces : clean the given string from all white spaces, \r and \n

func TestSetCookie

func TestSetCookie(cookieStr string)

TestSetCookie : set the cookie string to the given parameter

Types

type ComamndsToPath

type ComamndsToPath struct {
	Command int
	Path    string
}

ComamndsToPath : Convert between command index and the relevant path

type CommandToPath

type CommandToPath map[int]string

CommandToPath : hash map to convert between command and the relevant path

type Error

type Error struct {
	Code    int
	Message string
}

Error : Error struct definition: the code and the relevant message

func GetExpectedData

func GetExpectedData(sData string, okJ interface{}) (bool, string, string, Error, error)

GetExpectedData : check if the response data is as expected

type FileData

type FileData struct {
	FilePath string
}

FileData : the file path

type Match

type Match struct {
	Match   bool
	Message string // in case of error
}

Match : Match struct definition for OK and when fail, include the message to pass

type Secret

type Secret struct {
	Secret string
}

Secret : secret struct definition

type SecureFile

type SecureFile struct {
	FilePath string
	Secret   string
}

SecureFile : SecureFile struct definition: file path and the associated secret

type StringMessage

type StringMessage struct {
	Str string
}

StringMessage : StringMessage struct definition

type URL

type URL struct {
	URL string
}

URL : Uel struct definition

type UpdateSecret

type UpdateSecret struct {
	OldPassword string
	NewPassword string
}

UpdateSecret : UpdateSecret struct definition

Jump to

Keyboard shortcuts

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