rebbleHandlers

package
v0.0.0-...-ac755b3 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOCAL_BOOT_URI  string = "http://127.0.0.1:8080"
	PEBBLE_BOOT_URL string = "https://boot.getpebble.com/api/config/"
	STORE_URI       string = "https://store.rebble.io"
)

Variables

View Source
var StoreUrl string

StoreUrl contains the URL of the frontend for the Access-Control-Allow-Origin header

Functions

func AdminRebuildDBHandler

func AdminRebuildDBHandler(ctx *HandlerContext, w http.ResponseWriter, r *http.Request) (int, error)

AdminRebuildDBHandler allows an administrator to rebuild the database from the application directory after hitting a single API end point.

func AdminRebuildImagesHandler

func AdminRebuildImagesHandler(ctx *HandlerContext, w http.ResponseWriter, r *http.Request) (int, error)

AdminRebuildImagesHandler allows an administrator to rebuild the images database from the application directory after hitting a single API end point.

func AdminVersionHandler

func AdminVersionHandler(ctx *HandlerContext, w http.ResponseWriter, r *http.Request) (int, error)

AdminVersionHandler returns the latest build information from the host in-which it was built on, such as: The current application version, the host that built the binary, the date in-which the binary was built, and the current git commit hash. Build information is populated during builds triggered via the "make build" or "sup production deploy" commands.

func AppHandler

func AppHandler(ctx *HandlerContext, w http.ResponseWriter, r *http.Request) (int, error)

AppHandler returns a particular application from the backend DB as JSON

func AppsHandler

func AppsHandler(ctx *HandlerContext, w http.ResponseWriter, r *http.Request) (int, error)

AppsHandler lists all of the available applications from the backend DB.

func AuthorHandler

func AuthorHandler(ctx *HandlerContext, w http.ResponseWriter, r *http.Request) (int, error)

func BootHandler

func BootHandler(ctx *HandlerContext, w http.ResponseWriter, r *http.Request) (int, error)

BootHandler is based off of [@afourney|https://github.com/afourney]'s development bootstrap override.

func CollectionHandler

func CollectionHandler(ctx *HandlerContext, w http.ResponseWriter, r *http.Request) (int, error)

CollectionHandler serves a list of cards from a collection

func DummyHandler

func DummyHandler(w http.ResponseWriter, r *http.Request)

DummyHandler is useful for adding a route when the handler hasn't been completed/fleshed out yet.

func Handlers

func Handlers(context *HandlerContext) *mux.Router

Handlers returns a mux.Router with all possible routes already setup.

func HomeHandler

func HomeHandler(ctx *HandlerContext, w http.ResponseWriter, r *http.Request) (int, error)

HomeHandler is the index page.

func ImagesHandler

func ImagesHandler(ctx *HandlerContext, w http.ResponseWriter, r *http.Request) (int, error)

ImagesHandler serves a static image from PebbleImages/

func RecurseFolder

func RecurseFolder(w http.ResponseWriter, path string, f os.FileInfo, lvl int)

func SearchHandler

func SearchHandler(ctx *HandlerContext, w http.ResponseWriter, r *http.Request) (int, error)

SearchHandler is the search page

func TagsHandler

func TagsHandler(ctx *HandlerContext, w http.ResponseWriter, r *http.Request) (int, error)

TagsHandler returns the list of tags of a particular appliction as JSON

func VersionsHandler

func VersionsHandler(ctx *HandlerContext, w http.ResponseWriter, r *http.Request) (int, error)

VersionsHandler returns the server version

Types

type BootConfig

type BootConfig struct {
	Algolia        json.RawMessage   `json:"algolia"`
	AppMeta        json.RawMessage   `json:"app_meta"`
	Authentication json.RawMessage   `json:"authentication"`
	Cohorts        json.RawMessage   `json:"cohorts"`
	Developer      json.RawMessage   `json:"developer"`
	Health         json.RawMessage   `json:"health"`
	Href           string            `json:"href"`
	Id             string            `json:"id"`
	KeenIo         json.RawMessage   `json:"keen_io"`
	LinkedServices json.RawMessage   `json:"linked_services"`
	Links          json.RawMessage   `json:"links"`
	Locker         json.RawMessage   `json:"locker"`
	Notifications  json.RawMessage   `json:"notifications"`
	SupportRequest json.RawMessage   `json:"support_request"`
	Timeline       json.RawMessage   `json:"timeline"`
	TreasureData   json.RawMessage   `json:"treasure_data"`
	Voice          json.RawMessage   `json:"voice"`
	Webviews       map[string]string `json:"webviews"`
}

BootConfig contains the webviews from the JSON file.

type BootJSON

type BootJSON struct {
	Config BootConfig `json:"config"`
}

BootJSON is just a Go container object for the JSON response.

type HandlerContext

type HandlerContext struct {
	Database *db.Handler
}

HandlerContext is our struct for storing the data we want to inject in to each handler we can also add things like authorization level, user information, templates, etc.

type PebbleAppList

type PebbleAppList struct {
	Apps []*PebbleApplication `json:"data"`
}

PebbleAppList contains a list of PebbleApplication. It matches the format of Pebble API answers.

type PebbleApplication

type PebbleApplication struct {
	Id                 string                   `json:"id"`
	Name               string                   `json:"title"`
	Author             string                   `json:"author"`
	CategoryId         string                   `json:"category_id"`
	CategoryName       string                   `json:"category_name"`
	CategoryColor      string                   `json:"category_color"`
	Description        string                   `json:"description"`
	Published          db.JSONTime              `json:"published_date"`
	Release            PebbleApplicationRelease `json:"latest_release"`
	Website            string                   `json:"website"`
	Source             string                   `json:"source"`
	Screenshots        PebbleScreenshotImages   `json:"screenshot_images"`
	Icons              PebbleIcons              `json:"icon_image"`
	ScreenshotHardware string                   `json:"screenshot_hardware"`
	HeaderImages       PebbleHeaderImages       `json:"header_images"`
	Hearts             int                      `json:"hearts"`
	Type               string                   `json:"type"`
	Compatibility      PebbleCompatibility      `json:"compatibility"`
	Changelog          []PebbleVersion          `json:"changelog"`
}

PebbleApplication is used by the parseApp() function. It matches directly the `{id}.json` format.

type PebbleApplicationRelease

type PebbleApplicationRelease struct {
	Id        string      `json:"id"`
	PbwUrl    string      `json:"pbw_file"`
	Published db.JSONTime `json:"published_date"`
	Version   string      `json:"version"`
}

PebbleApplicationRelease describes the `release` tag of a pebble JSON

type PebbleCompatibility

type PebbleCompatibility struct {
	Ios     PebbleCompatibilityBool `json:"ios"`
	Android PebbleCompatibilityBool `json:"android"`
	Aplite  PebbleCompatibilityBool `json:"aplite"`
	Basalt  PebbleCompatibilityBool `json:"basalt"`
	Chalk   PebbleCompatibilityBool `json:"chalk"`
	Diorite PebbleCompatibilityBool `json:"diorite"`
}

PebbleCompatibility describes the `compatibility` tag of a pebble JSON

type PebbleCompatibilityBool

type PebbleCompatibilityBool struct {
	Supported bool `json:"supported"`
}

PebbleCompatibilityBool describes the contents of a `compatibility` tag of a pebble JSON

type PebbleHeaderImage

type PebbleHeaderImage struct {
	Orig string `json:"orig"`
}

PebbleHeaderImage is used by PebbleHeaderImages to allow mixed contents

type PebbleHeaderImages

type PebbleHeaderImages []PebbleHeaderImage

PebbleHeaderImages is a generic type to allow mixed contents (empty string or array of header images)

func (*PebbleHeaderImages) UnmarshalJSON

func (phi *PebbleHeaderImages) UnmarshalJSON(b []byte) error

UnmarshalJSON for PebbleHeaderImages allows for mixed content

type PebbleIcons

type PebbleIcons map[string]string

PebbleIcons contains the icon at varying resolutions

func (*PebbleIcons) UnmarshalJSON

func (pi *PebbleIcons) UnmarshalJSON(b []byte) error

type PebbleScreenshotImage

type PebbleScreenshotImage map[string]string

PebbleScreenshotImage is used by PebbleHeaderImages to allow mixed contents

type PebbleScreenshotImages

type PebbleScreenshotImages []PebbleScreenshotImage

PebbleScreenshotImages is a generic type to allow mixed contents (empty string or array of screenshots)

func (*PebbleScreenshotImages) UnmarshalJSON

func (psi *PebbleScreenshotImages) UnmarshalJSON(b []byte) error

UnmarshalJSON for PebbleScreenshotImages allows for mixed content

type PebbleVersion

type PebbleVersion struct {
	Version   string      `json:"version"`
	Published db.JSONTime `json:"published_date"`
	Notes     string      `json:"release_notes"`
}

PebbleVersion describes a version change

type RebbleChangelog

type RebbleChangelog struct {
	Versions []db.RebbleVersion `json:"versions"`
}

RebbleChangelog contains a list of version changes for an app

type RebbleCollection

type RebbleCollection struct {
	Id    string          `json:"id"`
	Name  string          `json:"name"`
	Pages int             `json:"pages"`
	Cards []db.RebbleCard `json:"cards"`
}

type RebbleTagList

type RebbleTagList struct {
	Tags []db.RebbleCollection `json:"tags"`
}

RebbleTagList contains a list of tag. Used by getApi(id)

type WebviewsConfig

type WebviewsConfig struct {
	FAQ                  string `json:"support/faq"`
	Application          string `json:"appstore/application"`
	ApplicationChangelog string `json:"appstore/application_changelog"`
	DeveloperApps        string `json:"appstore/developer_apps"`
	Watchfaces           string `json:"appstore/watchfaces"`
	Watchapps            string `json:"appstore/watchapps"`
}

WebviewConfig contains the webviews in-which we would like to override.

Jump to

Keyboard shortcuts

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