utils

package
v0.0.0-...-4e75552 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2020 License: Apache-2.0 Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clearln

func Clearln()

Clearln clears the last line from the console output

func ParseBasicAuthHeader

func ParseBasicAuthHeader(header string) (string, string)

ParseBasicAuthHeader decodes the Basic Auth header. First checks if the string contains the substring "Basic" and strips it off if present. Returns the username:password pair

func ParseParams

func ParseParams(str string) (map[string]string, error)

ParseParams parses a URL string containing application/x-www-urlencoded parameters and returns a map of string key-value pairs of the same

func PresentAuthScreen

func PresentAuthScreen(w http.ResponseWriter, r *http.Request, flow int)

PresentAuthScreen shows the authorization screen to the user

func RenderTemplate

func RenderTemplate(w http.ResponseWriter, r *http.Request, templateName string, status int, data interface{})

RenderTemplate renders the template with the given template, sets the status code for the response

func ShowError

func ShowError(w http.ResponseWriter, r *http.Request, status int, title string, desc string)

ShowError presents the error screen to the user

func ShowJSONError

func ShowJSONError(w http.ResponseWriter, r *http.Request, status int, data interface{})

ShowJSONError presents the error to the user or application in the form of a JSON string

func Sleep

func Sleep(duration time.Duration)

Sleep pauses the current goroutine for the specified duration

Types

type RequestError

type RequestError struct {
	Error string `json:"error"`
	Desc  string `json:"error_description"`
}

RequestError is used as response for failed requests. Using the necessary structures mentioned in RFC 6749 Section 4.1.2.1 (https://tools.ietf.org/html/rfc6749#section-4.1.2.1) error_uri is ignored since this is not a real API and has no documentation. state is ignored because it is ignored by flowHandlers.

Jump to

Keyboard shortcuts

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