utils

package
v0.0.0-...-176e0db Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateApiResponse

func CreateApiResponse(v interface{}) []byte

func CrudHandler

func CrudHandler(
	getHandler func(*mongo.Database, *User, http.ResponseWriter, *http.Request),
	createHandler func(*mongo.Database, *User, http.ResponseWriter, *http.Request),
	updateHandler func(*mongo.Database, *User, http.ResponseWriter, *http.Request),
	deleteHandler func(*mongo.Database, *User, http.ResponseWriter, *http.Request),
) func(http.ResponseWriter, *http.Request)

func ParseRequestBody

func ParseRequestBody(r *http.Request, v interface{}) error

func ServeFunction

func ServeFunction(url string, handler func(http.ResponseWriter, *http.Request))

func SetDefaultHeaders

func SetDefaultHeaders(w http.ResponseWriter)

Types

type AppMetaData

type AppMetaData struct {
	Provider string `json:"provider"`
}

type Identity

type Identity struct {
	URL   string `json:"url"`
	Token string `json:"token"`
}

type IdentityResponse

type IdentityResponse struct {
	Identity *Identity `json:"identity"`
	User     *User     `json:"user"`
	SiteUrl  string    `json:"site_url"`
}

type Response

type Response struct {
	Msg              string `json:"msg"`
	IdentityResponse string `json:"identity_response"`
}

type User

type User struct {
	Id           string        `json:"id"`
	AppMetaData  *AppMetaData  `json:"app_metadata"`
	Email        string        `json:"email"`
	Exp          int           `json:"exp"`
	Sub          string        `json:"sub"`
	Role         string        `json:"role"`
	UserMetadata *UserMetadata `json:"user_metadata"`
}

func GetAuthUser

func GetAuthUser(w http.ResponseWriter, r *http.Request) *User

type UserMetadata

type UserMetadata struct {
	FullName string `json:"full_name"`
}

Jump to

Keyboard shortcuts

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