image

package
v0.0.0-...-4711403 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2023 License: MPL-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const ComparatorRegexRule = `^(>=|<=|=|!=|>|<)[0-9]+$`
View Source
const RegexRule = `^[a-zA-Z0-9-]+$`

Variables

This section is empty.

Functions

func QueryParamsBinder

func QueryParamsBinder(
	favRoute bool,
	c echo.Context,
	isNsfw *string,
	includedTags *[]string,
	excludedTags *[]string,
	includedFiles *[]string,
	excludedFiles *[]string,
	gif *string,
	orderBy *string,
	orientation *string,
	many *bool,
	full *bool,
	width *string,
	height *string,
	byteSize *string,
) error

Types

type Controller

type Controller struct {
	Globals utils.Globals
}

func (Controller) Fav

func (controller Controller) Fav() echo.HandlerFunc

Fav handles the route selection for fetching favorite images. It retrieves images based on the user's favorites.

@Summary Fetch Favorite Images @Description Retrieves images based on the user's favorites. @Tags Favorites @Accept json @Produce json @Param included_tags query []string false "Force the API to return images with at least all the provided tags" @Param excluded_tags query []string false "Force the API to return images without any of the provided tags" @Param included_files query []string false "Force the API to provide only the specified file IDs or signatures" example(58e6f0372364abda) @Param excluded_files query []string false "Force the API to not list the specified file IDs or signatures" example(8108) @Param is_nsfw query string false "Force or exclude lewd files (only works if included_tags only contain versatile tags and no nsfw only tag). You can provide 'null' to make it be random." Enums(null, true, false) default(false) @Param gif query bool false "Force or prevent the API to return .gif files" @Param order_by query string false "Ordering criteria" Enums(FAVORITES, UPLOADED_AT, LIKED_AT, RANDOM) default(RANDOM) @Param orientation query string false "Image orientation" Enums(LANDSCAPE, PORTRAIT, RANDOM) default(RANDOM) @Param many query bool false "Return an array of 30 files if true" default(false) @Param full query bool false "Returns the full result without any limit (admins only)" default(false) @Param width query string false "Filter images by width (in pixels). Accepted operators: <=, >=, >, <, !=, =" example(>=2000) @Param height query string false "Filter images by height (in pixels). Accepted operators: <=, >=, >, <, !=, =" example(>=2000) @Param byte_size query string false "Filter images by byte size. Accepted operators: <=, >=, >, <, !=, =" example(>=2000) @Param user_id query int64 false "User ID" @Security ApiKeyAuth @Success 200 {object} serializers.ImagesJsonResponse @Failure default {object} serializers.JSONError @Router /fav [get]

func (Controller) RouteSelector

func (controller Controller) RouteSelector(favRoute bool) echo.HandlerFunc

RouteSelector Since most of the code is the same for /fav and /search I wrap the handler inside a function Then the handler use the 'parent' function favRoot boolean to know if it should add or not the user id to constants methods The parent function is itself a method of Root so that it can access api package globals variables (api.Globals struct)

func (Controller) Search

func (controller Controller) Search() echo.HandlerFunc

Search handles the route selection based on the specified parameters. It retrieves images randomly or by tag. If no tag filtering is requested, the default tag "waifu" will be included.

@Summary Search Images @Description Retrieves images randomly or by tag based on the specified search criteria. @Tags Get Images @Accept json @Produce json @Param included_tags query []string false "Force the API to return images with at least all the provided tags" @Param excluded_tags query []string false "Force the API to return images without any of the provided tags" @Param included_files query []string false "Force the API to provide only the specified file IDs or signatures" example(58e6f0372364abda) @Param excluded_files query []string false "Force the API to not list the specified file IDs or signatures" example(8108) @Param is_nsfw query string false "Force or exclude lewd files (only works if included_tags only contain versatile tags and no nsfw only tag). You can provide 'null' to make it be random." Enums(null, true, false) default(false) @Param gif query bool false "Force or prevent the API to return .gif files" @Param order_by query string false "Ordering criteria" Enums(FAVORITES, UPLOADED_AT, LIKED_AT, RANDOM) default(RANDOM) @Param orientation query string false "Image orientation" Enums(LANDSCAPE, PORTRAIT, RANDOM) default(RANDOM) @Param many query bool false "Return an array of 30 files if true" default(false) @Param full query bool false "Returns the full result without any limit (admins only)" default(false) @Param width query string false "Filter images by width (in pixels). Accepted operators: <=, >=, >, <, !=, =" example(>=2000) @Param height query string false "Filter images by height (in pixels). Accepted operators: <=, >=, >, <, !=, =" example(>=2000) @Param byte_size query string false "Filter images by byte size. Accepted operators: <=, >=, >, <, !=, =" example(>=2000) @Security ApiKeyAuth @Success 200 {object} serializers.ImagesJsonResponse @Failure default {object} serializers.JSONError @Router /search [get]

Jump to

Keyboard shortcuts

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