app

package
v0.0.0-...-fc62e3d Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2021 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = &ErrResponse{HTTPStatusCode: 404, StatusText: "Resource not found."}

Functions

func Create

func Create(t Context) http.HandlerFunc

func Delete

func Delete(t Context) http.HandlerFunc

func ErrInternal

func ErrInternal(err error) render.Renderer

func ErrInvalidRequest

func ErrInvalidRequest(err error) render.Renderer

func ErrRender

func ErrRender(err error) render.Renderer

func ErrUnauthorized

func ErrUnauthorized(err error) render.Renderer

func List

func List(t Context) http.HandlerFunc

func Router

func Router(ctx context.Context, cfg Config) chi.Router

func UpdateStatus

func UpdateStatus(t Context) http.HandlerFunc

func UpdateText

func UpdateText(t Context) http.HandlerFunc

Types

type APIRoute

type APIRoute struct {
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

type AccountForm

type AccountForm struct {
	Name          string
	Email         string
	ResetAPIToken bool
	FormToken     string
}

func (*AccountForm) FieldMap

func (af *AccountForm) FieldMap(_ *http.Request) binding.FieldMap

Fieldmap for the accountform. extend it for more fields

type Config

type Config struct {
	Name             string `json:"name" default:"gomodest"`
	Domain           string `json:"domain" default:"https://gomodest.xyz"`
	Port             int    `json:"port" default:"4000"`
	HealthPath       string `json:"health_path" envconfig:"health_path" default:"/healthz"`
	ReadTimeoutSecs  int    `json:"read_timeout_secs" envconfig:"read_timeout_secs" default:"5"`
	WriteTimeoutSecs int    `json:"write_timeout_secs" envconfig:"write_timeout_secs" default:"10"`
	LogLevel         string `json:"log_level" envconfig:"log_level" default:"error"`
	LogFormatJSON    bool   `json:"log_format_json" envconfig:"log_format_json" default:"false"`
	Templates        string `json:"templates" envconfig:"templates" default:"templates"`
	SessionSecret    string `json:"session_secret" envconfig:"session_secret" default:"mysessionsecret"`
	APIMasterSecret  string `json:"api_master_secret" envconfig:"api_master_secret" default:"supersecretkeyyoushouldnotcommit"`

	// datasource
	Driver     string `json:"driver" envconfig:"driver" default:"sqlite3"`
	DataSource string `json:"datasource" envconfig:"datasource" default:"file:gomodest.db?mode=memory&cache=shared&_fk=1"`

	// smtp
	SMTPHost       string `json:"smtp_host" envconfig:"smtp_host" default:"0.0.0.0"`
	SMTPPort       int    `json:"smtp_port,omitempty" envconfig:"smtp_port" default:"1025"`
	SMTPUser       string `json:"smtp_user" envconfig:"smtp_user" default:"myuser" `
	SMTPPass       string `json:"smtp_pass,omitempty" envconfig:"smtp_pass" default:"mypass"`
	SMTPAdminEmail string `json:"smtp_admin_email" envconfig:"smtp_admin_email" default:"noreply@gomodest.xyz"`
	SMTPDebug      bool   `json:"smtp_debug" envconfig:"smtp_debug" default:"true"`

	// goth
	GoogleClientID string `json:"google_client_id" envconfig:"google_client_id"`
	GoogleSecret   string `json:"google_secret" envconfig:"google_secret"`

	// subscription
	FeatureGroupsFile    string         `json:"feature_groups_file" envconfig:"feature_groups_file" default:"feature_groups.development.json"`
	FeatureGroups        []FeatureGroup `json:"-" envconfig:"-"`
	PlansFile            string         `json:"plans_file" envconfig:"plans_file" default:"plans.development.json"`
	Plans                []Plan         `json:"-" envconfig:"-"`
	StripePublishableKey string         `json:"stripe_publishable_key" envconfig:"stripe_publishable_key"`
	StripeSecretKey      string         `json:"stripe_secret_key" envconfig:"stripe_secret_key"`
	StripeWebhookSecret  string         `json:"stripe_webhook_secret" envconfig:"stripe_webhook_secret"`
}

func LoadConfig

func LoadConfig(configFile string, envPrefix string) (Config, error)

type Context

type Context struct {
	// contains filtered or unexported fields
}

type ErrResponse

type ErrResponse struct {
	Err            error `json:"-"` // low-level runtime error
	HTTPStatusCode int   `json:"-"` // http response status code

	StatusText string `json:"status"`          // user-level status message
	AppCode    int64  `json:"code,omitempty"`  // application-specific error code
	ErrorText  string `json:"error,omitempty"` // application-level error message, for debugging
}

ErrResponse renderer type for handling all sorts of errors.

In the best case scenario, the excellent github.com/pkg/errors package helps reveal information on the error, setting it on Err, and in the Render() method, using it to set the application-specific error code in AppCode.

func (*ErrResponse) Render

func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error

type Feature

type Feature struct {
	ID        string `json:"id"`
	Title     string `json:"title"`
	ValueType string `json:"value_type"`
}

type FeatureGroup

type FeatureGroup struct {
	Name     string    `json:"name"`
	Features []Feature `json:"features"`
}

type LoginForm

type LoginForm struct {
	Email    string `json:"email"`
	Password string `json:"password"`
	Magic    string `json:"magic"`
}

func (*LoginForm) Bind

func (l *LoginForm) Bind(_ *http.Request) error

func (*LoginForm) FieldMap

func (l *LoginForm) FieldMap(_ *http.Request) binding.FieldMap

Fieldmap for the LoginData

type Plan

type Plan struct {
	PriceID  string                 `json:"price_id"`
	Name     string                 `json:"name"`
	Price    string                 `json:"price"`
	Current  bool                   `json:"-"`
	Details  []string               `json:"details"`
	Features map[string]interface{} `json:"features"`

	StripeKey string `json:"-"`
}

type ResetForm

type ResetForm struct {
	Password string
}

func (*ResetForm) FieldMap

func (rf *ResetForm) FieldMap(_ *http.Request) binding.FieldMap

Fieldmap for the ResetForm. extend it for more fields

Jump to

Keyboard shortcuts

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