awesomemy

package module
v0.0.0-...-2b115c7 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 10 Imported by: 0

README

AwesomeMY

Your all-in-one hub for exploring groundbreaking innovations, disruptive startups, exclusive insights, and dynamic events shaping the Malaysian tech scene.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CtxKeyLogger   = ctxKey{"awesomemy.logger"}
	CtxKeyConfig   = ctxKey{"awesomemy.config"}
	CtxKeyAuthUser = ctxKey{"awesomemy.auth.user"}
)

Functions

func MustContextValue

func MustContextValue[T any](ctx context.Context, key ctxKey) T

MustContextValue retrieves a context value of type T with the given key. If the assertion fails, it panics.

func PageLimitOffsetFromRequest

func PageLimitOffsetFromRequest(r *http.Request) (int, int, int)

PageLimitOffsetFromRequest extracts the page, limit and offset from an HTTP request.

Types

type AuthenticationConfig

type AuthenticationConfig struct {
	Session struct {
		Prefix   string   `yaml:"prefix"`
		Name     string   `yaml:"name"`
		Persist  bool     `yaml:"persist"`
		SameSite string   `yaml:"same_site"`
		Secure   bool     `yaml:"secure"`
		Lifetime Duration `yaml:"lifetime"`
	} `yaml:"session"`
	OAuth2 AuthenticationOAuth2Config `yaml:"oauth2"`
}

type AuthenticationOAuth2Config

type AuthenticationOAuth2Config struct {
	GitHub struct {
		ClientID     string `yaml:"client_id"`
		ClientSecret string `yaml:"client_secret"`
	} `yaml:"github"`
}

func (AuthenticationOAuth2Config) OAuth2Config

func (aac AuthenticationOAuth2Config) OAuth2Config(provider string) *oauth2.Config

type Config

type Config struct {
	Postgres        PostgresConfig       `yaml:"postgres"`
	Redis           RedisConfig          `yaml:"redis"`
	Http            HttpConfig           `yaml:"http"`
	Authentication  AuthenticationConfig `yaml:"authentication"`
	FrontendBaseURL string               `yaml:"frontend_base_url"`
}

func ParseConfig

func ParseConfig(b []byte) (Config, error)

func ParseConfigFromFile

func ParseConfigFromFile(fp string) (Config, error)

type Duration

type Duration struct {
	time.Duration
}

Duration represents a duration with YAML unmarshalling support.

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(b []byte) error

UnmarshalYAML unmarshals a YAML duration into a time.Duration.

type HttpConfig

type HttpConfig struct {
	Host string `yaml:"host"`
	Port int    `yaml:"port"`
	Cors struct {
		Origin []string `yaml:"origin"`
	} `yaml:"cors"`
}

func (HttpConfig) Address

func (hc HttpConfig) Address() string

type PaginationMeta

type PaginationMeta struct {
	CurrentPage int `json:"current_page"`
	TotalPages  int `json:"total_pages"`
	Count       int `json:"count"`
	Total       int `json:"total"`
}

func NewPaginationMeta

func NewPaginationMeta(currentPage, count, total int) PaginationMeta

type PostgresConfig

type PostgresConfig struct {
	Name     string `yaml:"name"`
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
}

func (PostgresConfig) DSN

func (pc PostgresConfig) DSN() string

type RedisConfig

type RedisConfig struct {
	Host string `yaml:"host"`
	Port int    `yaml:"port"`
}

func (RedisConfig) ConnnectionString

func (rc RedisConfig) ConnnectionString() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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