ogpapp

package module
v0.0.0-...-12bc185 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: MIT Imports: 19 Imported by: 0

README

ogp-app

ogp app generates ogp:image with the text user assigned.

Prerequisite for development

TODO: To be documented

Production Environment

Currently, ogp.app is running on Google Compute Engine.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateInitialPoint

func CalculateInitialPoint(s string, opt *DrawStringOpts)

CalculateInitialPoint calculate starting point

func DrawStringWrapped

func DrawStringWrapped(d *font.Drawer, s string, opt *DrawStringOpts)

DrawStringWrapped draw string wrapped

func LoggingMiddleware

func LoggingMiddleware(next http.Handler) http.Handler

LoggingMiddleware logging

func MeasureString

func MeasureString(f font.Face, s string) (advance fixed.Int26_6)

MeasureString returns how far dot would advance by drawing s with f.

func RecoverMiddleware

func RecoverMiddleware(next http.Handler) http.Handler

RecoverMiddleware panic recovery

Types

type App

type App struct {
	Config        *Config
	KoruriBold    *truetype.Font
	OgpPagePath   string
	IndexPagePath string
	OgpPageTmpl   *template.Template
	IndexPageTmpl *template.Template
}

App ogp.app

func NewApp

func NewApp(cfg *Config) (*App, error)

NewApp create app

func (*App) CreateImage

func (app *App) CreateImage(w http.ResponseWriter, r *http.Request)

CreateImage create ogp image API

func (*App) IndexPage

func (app *App) IndexPage(w http.ResponseWriter, r *http.Request)

IndexPage display index page

func (*App) OgpPage

func (app *App) OgpPage(w http.ResponseWriter, r *http.Request)

OgpPage display ogp page

type Config

type Config struct {
	BaseURL            string  `toml:"base_url"`
	APIServerPort      string  `toml:"api_server_port"`
	TLS                bool    `toml:"tls"`
	KoruriBoldFontPath string  `toml:"koruri_bold_font_path"`
	DefaultImageWidth  int     `toml:"default_image_width"`
	DefaultImageHeight int     `toml:"default_image_height"`
	DefaultFontSize    float64 `toml:"default_font_size"`
	LocalDev           bool    `toml:"local_dev"`
	ServerCertPath     string  `toml:"server_cert_path"`
	ServerKeyPath      string  `toml:"server_key_path"`
}

Config ogp.app config

func NewConfig

func NewConfig(path string) (*Config, error)

NewConfig create app config

type DrawStringOpts

type DrawStringOpts struct {
	ImageWidth       fixed.Int26_6
	ImageHeight      fixed.Int26_6
	VerticalMargin   fixed.Int26_6
	HorizontalMargin fixed.Int26_6
	FontSize         fixed.Int26_6
	LineSpace        fixed.Int26_6
	Verbose          bool
}

DrawStringOpts options

type Server

type Server struct {
	App    *App
	Config *Config
	Mux    *mux.Router
}

Server server

func NewServer

func NewServer(cfgFile string) (*Server, error)

NewServer creates server

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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