common

package
v0.0.0-...-9681a29 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupLogger

func SetupLogger()

/ TODO : take a prefix to know where the logs come / from. E..g "[URCHIN]" and "[URCHIN-ADMIN]"

Types

type AppSettings

type AppSettings struct {
	DatabaseAddress  string `toml:"database_address"`
	DatabasePort     int    `toml:"database_port"`
	DatabaseUser     string `toml:"database_user"`
	DatabasePassword string `toml:"database_password"`
	DatabaseName     string `toml:"database_name"`
	WebserverPort    int    `toml:"webserver_port"`
	AdminPort        int    `toml:"admin_port"`
	ImageDirectory   string `toml:"image_dir"`
	CacheEnabled     bool   `toml:"cache_enabled"`
	RecaptchaSiteKey string `toml:"recaptcha_sitekey,omitempty"`
	RecaptchaSecret  string `toml:"recaptcha_secret,omitempty"`
	AppNavbar        Navbar `toml:"navbar"`
}

func ReadConfigToml

func ReadConfigToml(filepath string) (AppSettings, error)

type ErrorResponse

type ErrorResponse struct {
	Msg string `json:"msg"`
	Err string `json:"error,omitempty"`
}

Supported responses for urchin shared between app and admin-app.

func ErrorRes

func ErrorRes(msg string, err error) ErrorResponse

Convenience method to create an error response with the given message and adding the error message as well.

msg: message to add to the error response err: error occurred during process of request.

func MsgErrorRes

func MsgErrorRes(msg string) ErrorResponse

Convenience method to create an error response with the given message only.

msg: message to add to the error response

type Image

type Image struct {
	Uuid    string `json:"uuid"`
	Name    string `json:"name"`
	AltText string `json:"alt_text"`
	Ext     string `json:"extension"`
}

type ImageIdBinding

type ImageIdBinding struct {
	// This is the uuid of an image to be retrieved
	Filename string `uri:"name" binding:"required"`
}

type IntIdBinding

type IntIdBinding struct {
	Id int `uri:"id" binding:"required"`
}
type Link struct {
	Name  string
	Href  string
	Title string
}
type Navbar struct {
	Links []Link `toml:"links"`
}

type Post

type Post struct {
	Title   string `json:"title"`
	Content string `json:"content"`
	Excerpt string `json:"excerpt"`
	Id      int    `json:"id"`
}

type PostIdBinding

type PostIdBinding struct {
	IntIdBinding
}

type StringIdBinding

type StringIdBinding struct {
	Id string `uri:"id" binding:"required"`
}

Jump to

Keyboard shortcuts

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