rest

package
v0.1.1-beta.2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: MIT Imports: 26 Imported by: 1

Documentation

Overview

Author xc, Created on 2020-10-1 12:50 {COPYRIGHTS}

Author xc, Created on 2019-08-11 16:49 {COPYRIGHTS}

Author xc, Created on 2019-08-13 17:25 {COPYRIGHTS}

Index

Constants

View Source
const StatusExpired = 440
View Source
const StatusNotFound = 404
View Source
const StatusServer = 500
View Source
const StatusUnauthed = 403
View Source
const StatusWrongParams = 400

Variables

View Source
var ACCESS_MANAGE_ACCESS = "access/manage"

Functions

func AllRoles

func AllRoles(w http.ResponseWriter, r *http.Request)

func AssignCreateRole

func AssignCreateRole(w http.ResponseWriter, r *http.Request)

func AssignUserRoles

func AssignUserRoles(w http.ResponseWriter, r *http.Request)

func AssignedUsers

func AssignedUsers(w http.ResponseWriter, r *http.Request)

func AuthAuthenticate

func AuthAuthenticate(w http.ResponseWriter, r *http.Request)

AuthAuthenticate generate refresh toke and access token based on username and password

func AuthRenewAccessToken

func AuthRenewAccessToken(w http.ResponseWriter, r *http.Request)

Renew access token

func AuthRevokeRefreshToken

func AuthRevokeRefreshToken(w http.ResponseWriter, r *http.Request)

func BuildLimit

func BuildLimit(r *http.Request) ([]int, error)

func BuildSortby

func BuildSortby(r *http.Request) []string

func CheckUserID

func CheckUserID(context context.Context, w http.ResponseWriter) int

Check if there is user id, if not output error and return 0

func ClearDebugToken

func ClearDebugToken(w http.ResponseWriter, r *http.Request)

func Copy

func Copy(w http.ResponseWriter, r *http.Request)

copy old data

func Create

func Create(w http.ResponseWriter, r *http.Request)

func CurrentUser

func CurrentUser(w http.ResponseWriter, r *http.Request)

Get current user

func CurrentUserEditField

func CurrentUserEditField(w http.ResponseWriter, r *http.Request)

Get current user's updatefields on him/herself

func Delete

func Delete(w http.ResponseWriter, r *http.Request)

func EnableUser

func EnableUser(w http.ResponseWriter, r *http.Request)

func FetchUserRoles

func FetchUserRoles(w http.ResponseWriter, r *http.Request)

func GenerateDebugToken

func GenerateDebugToken(w http.ResponseWriter, r *http.Request)

func GetAllDefinitions

func GetAllDefinitions(w http.ResponseWriter, r *http.Request)

func GetAllowedLimitations

func GetAllowedLimitations(w http.ResponseWriter, r *http.Request)

func GetContent

func GetContent(w http.ResponseWriter, r *http.Request)

func GetDefinition

func GetDefinition(w http.ResponseWriter, r *http.Request)

todo: check permission

func GetVersion

func GetVersion(w http.ResponseWriter, r *http.Request)

func HandleError

func HandleError(err error, w http.ResponseWriter, httpCode ...int)

func HandleRoute

func HandleRoute(router *mux.Router)

Handle route with context. eg. user Loop registered route and listen handle function

func HandleUploadFile

func HandleUploadFile(r *http.Request, filetype string) (string, error)

Handler uploaded file, return filename & error

func InitRequest

func InitRequest(next http.Handler) http.Handler

Initialize request, including set context. todo: support callback

func List

func List(w http.ResponseWriter, r *http.Request)

List

func Move

func Move(w http.ResponseWriter, r *http.Request)

func RegisterRoute

func RegisterRoute(path string, funcHandler func(http.ResponseWriter, *http.Request), methods ...string)

func RelationOptionList

func RelationOptionList(w http.ResponseWriter, r *http.Request)

Get content list from relation definition

func ResetPassword

func ResetPassword(w http.ResponseWriter, r *http.Request)

todo: move this into user logic under core/user or handler/user.go folder

func ResetPasswordDone

func ResetPasswordDone(w http.ResponseWriter, r *http.Request)

todo: move this to logic

func SaveDraft

func SaveDraft(w http.ResponseWriter, r *http.Request)

Save draft. url: /<id>/<ctype> where id can be 0 or parent location id request json: data: string(mostly json string) return new created time

func SetPriority

func SetPriority(w http.ResponseWriter, r *http.Request)

func TreeMenu

func TreeMenu(w http.ResponseWriter, r *http.Request)

Get tree menu under a node

func UnassignUser

func UnassignUser(w http.ResponseWriter, r *http.Request)

unassign user from role

func Update

func Update(w http.ResponseWriter, r *http.Request)

func UploadFile

func UploadFile(w http.ResponseWriter, r *http.Request)

func UploadImage

func UploadImage(w http.ResponseWriter, r *http.Request)

Upload image, return path or error

func UserRoles

func UserRoles(w http.ResponseWriter, r *http.Request)

func Validate

func Validate(w http.ResponseWriter, r *http.Request)

func VerifyAccessToken

func VerifyAccessToken(r *http.Request) (error, auth.UserClaims)

func WriteResponse

func WriteResponse(data interface{}, w http.ResponseWriter, isError ...bool)

Types

type Activiation

type Activiation struct {
	ID      int    `boil:"id" json:"id" toml:"id" yaml:"id"`
	Created int    `boil:"created" json:"created" toml:"created" yaml:"created"`
	Hash    string `boil:"hash" json:"hash" toml:"hash" yaml:"hash"`

	//type. eg. resetpassword
	Type string `boil:"type" json:"type" toml:"type" yaml:"type"`
	//reference. eg. userid
	Ref string `boil:"ref" json:"ref" toml:"ref" yaml:"ref"`
}

todo: move this into entity folder

type AuthInput

type AuthInput struct {
	Username   string `json:"username"`
	Password   string `json:"password"`
	RememberMe bool   `json:"rememberme"`
}

type ResultItem

type ResultItem map[string]interface{}

Result item in the list

type ResultList

type ResultList []ResultItem

Result list

Jump to

Keyboard shortcuts

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