helpers

package
v0.0.0-...-ecfc40b Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind(w http.ResponseWriter, r *http.Request, out any) bool

Bind decodes json into object

func EventLog

func EventLog(r *http.Request, action EventLogType, item EventLogItem)

func GetFromContext

func GetFromContext(r *http.Request, key string) any

func GetIntParam

func GetIntParam(name string, w http.ResponseWriter, r *http.Request) (int, error)

GetIntParam fetches a parameter from the route variables as an integer redirects to a 404 or writes bad request state depending on error state

func GetOkFromContext

func GetOkFromContext(r *http.Request, key string) (res any, ok bool)

func GetStrParam

func GetStrParam(name string, w http.ResponseWriter, r *http.Request) (string, error)

GetStrParam fetches a parameter from the route variables as an integer redirects to a 404 or writes bad request state depending on error state

func QueryParams

func QueryParams(url *url.URL) db.RetrieveQueryParams

func QueryParamsForProps

func QueryParamsForProps(url *url.URL, props db.ObjectProps) (params db.RetrieveQueryParams)

func QueryParamsWithOwner

func QueryParamsWithOwner(url *url.URL, props db.ObjectProps) db.RetrieveQueryParams

func SetContextValue

func SetContextValue(r *http.Request, key string, value any) *http.Request

func Store

func Store(r *http.Request) db.Store

func UserFromContext

func UserFromContext(r *http.Request) *db.User

func WriteError

func WriteError(w http.ResponseWriter, err error)

func WriteErrorStatus

func WriteErrorStatus(w http.ResponseWriter, err string, code int)

func WriteJSON

func WriteJSON(w http.ResponseWriter, code int, out any)

WriteJSON writes object as JSON

Types

type EventLogItem

type EventLogItem struct {
	IntegrationID int
	UserID        int
	ProjectID     int

	ObjectType  db.EventObjectType
	ObjectID    int
	Description string
}

type EventLogType

type EventLogType string
const (
	EventLogCreate EventLogType = "create"
	EventLogUpdate EventLogType = "update"
	EventLogDelete EventLogType = "delete"
)

type H

type H map[string]any

H just a string-to-anything map

Jump to

Keyboard shortcuts

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