Documentation ¶
Overview ¶
Provide a simple JSON response with a customizable delay
Index ¶
- Constants
- Variables
- func CaseInsensitiveContains(s, substr string) bool
- func EnableCors(next http.HandlerFunc) http.HandlerFunc
- func Filter(vs []string, f func(string) bool) []string
- func GetHost(r *http.Request) string
- func GetOrigin(r *http.Request) string
- func GetSourceOrigin(r *http.Request) string
- func InitAmpAccess()
- func InitAmpAnalytics()
- func InitAmpCache()
- func InitAmpConsent()
- func InitAmpEmail()
- func InitAmpForm()
- func InitAmpInputmask()
- func InitAmpLiveList()
- func InitAmpStoryAutoAds()
- func InitAutosuggestSample()
- func InitCheckout()
- func InitCommentSection()
- func InitEcho()
- func InitFavoriteSample()
- func InitHotelSample()
- func InitHousingForm()
- func InitOAuth()
- func InitPackager()
- func InitPagedListSample()
- func InitPollSample()
- func InitProductBrowse()
- func InitRatingSample()
- func InitRedirects()
- func InitSeatmapPage()
- func InitSlowResponseSample()
- func InitStateRefreshSection()
- func InitStatic()
- func IsInsecureRequest(r *http.Request) bool
- func Min(x, y int) int
- func RedirectToSecureVersion(w http.ResponseWriter, r *http.Request)
- func RegisterHandler(pattern string, handler http.HandlerFunc)
- func RegisterSample(samplePath string, handler func(http.ResponseWriter, *http.Request, Page))
- func RegisterSampleEndpoint(samplePath string, name string, ...)
- func RegisterTemplate(route string, mode string, templatePath string, ...)
- func SendAmpListItems(w http.ResponseWriter, data ...interface{})
- func SendJsonError(w http.ResponseWriter, code int, data interface{})
- func SendJsonFile(w http.ResponseWriter, filePath string)
- func SendJsonResponse(w http.ResponseWriter, data interface{})
- func SetContentTypeJson(w http.ResponseWriter)
- func SetDefaultMaxAge(w http.ResponseWriter)
- func SetMaxAge(w http.ResponseWriter, age int)
- func SetVary(h http.Handler) http.Handler
- type AccessData
- type AmpListResponse
- type ArticleBody
- type Author
- type AuthorizationResponse
- type BlogItem
- type BlogPosting
- type ByPriceAsc
- type ByPriceDesc
- type ClientId
- type Comment
- type HotelAuthorizationResponse
- type Image
- type JsonRoot
- type Key
- type LRUCache
- type LiveBlogSample
- type MortgageForm
- type Page
- type PagedResponse
- type Poll
- type PollAnswer
- type PollEntryResult
- type PollForm
- type PollQuestions
- type PollResult
- type Product
- type ProductBrowsePage
- type ProductListing
- type ProductPage
- type Publisher
- type Redirect
- type Score
- type Seat
- type SeatJsonRoot
- type ShoppingCartItem
Constants ¶
const ( AMP_ACCESS_SAMPLE_PATH = "/" + CATEGORY_COMPONENTS + "/amp-access/" AMP_ACCESS_COOKIE = "ABE_LOGGED_IN" )
const ( ERROR_CASE_AMP_FORM = "error" SAMPLE_NAME = "/" + CATEGORY_COMPONENTS + "/amp-form/" )
const ( AMP_LIVE_LIST_COOKIE_NAME = "ABE_AMP_LIVE_LIST_STATUS" FIFTEEN_SECONDS = 15 MAX_BLOG_ITEMS_NUMBER_PER_PAGE = 5 BLOG_ID_PREFIX = "post" )
const ( COMMENT_SAMPLE_PATH = "/" + CATEGORY_SAMPLE_TEMPLATES + "/comment_section/" USER = "Mark" )
const ( DIST_FOLDER = "dist" TEMPLATE_FOLDER = "templates" AMP_CLIENT_ID_COOKIE = "AMP_ECID_GOOGLE" CATEGORY_ADVANCED = "advanced" CATEGORY_COMPONENTS = "components" CATEGORY_SAMPLE_TEMPLATES = "samples_templates" // Where to find the SXG service (i.e. host running https://github.com/ampproject/amppackager) PACKAGER_PREFIX = "https://amp-by-example-sxg.appspot.com/" )
const ( ECHO_ENDPOINT = "/echo" MAX_FORM_SIZE = 1024 * 100 )
const ( AMP_FAVORITE_COOKIE = "amp-favorite" AMP_FAVORITE_COUNT_COOKIE = "amp-favorite-with-count" )
const ( ERROR_CASE_HOUSING = "error" HOUSING_SAMPLE_PATH = "/" + CATEGORY_SAMPLE_TEMPLATES + "/housing/" )
const ( PAGED_LIST_SAMPLE_PATH = "/" + CATEGORY_ADVANCED + "/paged_list/" MAX_PAGE_COUNT = 5 ITEMS_PER_PAGE = 4 )
const ( ERROR_CASE_POLL = "error" POLL_SAMPLE_PATH = "/" + CATEGORY_SAMPLE_TEMPLATES + "/poll/" POLL_ANSWER = "PollAnswer" ALREADY_VOTED_MESSAGE = "You have already answered this poll. If you want to run this sample again, use an incognito window." THANKS_MESSAGE = "Thanks for answering the poll!" POLL_COOKIE_NAME = "POLL_USER_ID" )
const ( SEARCH = "search" SHOPPING_CART = "shopping_cart" ADD_TO_CART_PATH = "/samples_templates/product_page/add_to_cart" ABE_CLIENT_ID = "ABE_CLIENT_ID" SHOW_MORE_PATH = "/json/more_related_products_page" )
const ( SLOW_JSON_SAMPLE_PATH = "/" + CATEGORY_SAMPLE_TEMPLATES + "/slow-json/" SLOW_JSON_WITH_ITEMS_SAMPLE_PATH = "/" + CATEGORY_SAMPLE_TEMPLATES + "/slow-json-with-items/" SLOW_IFRAME_SAMPLE_PATH = "/" + CATEGORY_SAMPLE_TEMPLATES + "/slow-iframe/" )
const ( MAX_AGE_IN_SECONDS = 180 // three minutes OLD_ADDRESS = "amp-by-example.appspot.com" DIST_DIR = "dist" )
const (
AMP_INPUTMASK_SAMPLE_NAME = "/" + CATEGORY_COMPONENTS + "/amp-inputmask/"
)
const (
AUTOSUGGEST_SAMPLE_PATH = "/" + CATEGORY_ADVANCED + "/autosuggest/"
)
const (
BIND_SAMPLE_PATH = "/" + CATEGORY_COMPONENTS + "/time/"
)
const (
CONSENT_SAMPLE_PATH = "/" + CATEGORY_SAMPLE_TEMPLATES + "/consent/"
)
const DEFAULT_MAX_AGE = 60
const (
EMAIL_BASE_PATH = "/amphtml-email/"
)
const HOST = "https://ampbyexample.com"
const (
HOTEL_SAMPLE_PATH = "/" + CATEGORY_SAMPLE_TEMPLATES + "/hotel/"
)
const NEW_ADDRESS = "https://ampbyexample.com"
const NUMBER_OF_CONFIGS = 5
const (
OAUTH_BASE = "/oauth/"
)
const (
RATING_SAMPLE_PATH = "/" + CATEGORY_SAMPLE_TEMPLATES + "/rating/"
)
const SHOPPING_CART_TOTAL = 9.94
Variables ¶
var MODES = [...]string{"", "/embed", "/source", "/preview", "/preview/embed"}
Functions ¶
func CaseInsensitiveContains ¶
func EnableCors ¶
func EnableCors(next http.HandlerFunc) http.HandlerFunc
func GetSourceOrigin ¶
func InitAmpAccess ¶
func InitAmpAccess()
func InitAmpAnalytics ¶
func InitAmpAnalytics()
func InitAmpCache ¶
func InitAmpCache()
func InitAmpConsent ¶
func InitAmpConsent()
func InitAmpEmail ¶
func InitAmpEmail()
func InitAmpForm ¶
func InitAmpForm()
func InitAmpInputmask ¶
func InitAmpInputmask()
func InitAmpLiveList ¶
func InitAmpLiveList()
func InitAmpStoryAutoAds ¶
func InitAmpStoryAutoAds()
func InitAutosuggestSample ¶
func InitAutosuggestSample()
func InitCheckout ¶
func InitCheckout()
func InitCommentSection ¶
func InitCommentSection()
func InitFavoriteSample ¶
func InitFavoriteSample()
func InitHotelSample ¶
func InitHotelSample()
func InitHousingForm ¶
func InitHousingForm()
func InitPackager ¶
func InitPackager()
func InitPagedListSample ¶
func InitPagedListSample()
func InitPollSample ¶
func InitPollSample()
func InitProductBrowse ¶
func InitProductBrowse()
func InitRatingSample ¶
func InitRatingSample()
func InitRedirects ¶
func InitRedirects()
func InitSeatmapPage ¶
func InitSeatmapPage()
func InitSlowResponseSample ¶
func InitSlowResponseSample()
func InitStateRefreshSection ¶
func InitStateRefreshSection()
func InitStatic ¶
func InitStatic()
func IsInsecureRequest ¶
func RedirectToSecureVersion ¶
func RedirectToSecureVersion(w http.ResponseWriter, r *http.Request)
func RegisterHandler ¶
func RegisterHandler(pattern string, handler http.HandlerFunc)
func RegisterSample ¶
RegisterSample adds routes for different sample modes, e.g. (my_sample/embed, my_sample/preview,..). Use it whenever a sample requires a custom backend logic.
func RegisterSampleEndpoint ¶
func RegisterSampleEndpoint(samplePath string, name string, handler func(http.ResponseWriter, *http.Request, Page))
RegisterSampleEndpoint adds routes for different sample modes ((my_sample/search/embed, my_sample/search/preview,..)). Use this for samples requiring additional mode specific endpoints.
func RegisterTemplate ¶
func RegisterTemplate(route string, mode string, templatePath string, handler func(http.ResponseWriter, *http.Request, Page))
RegisterTemplate configures a handler for requests rendering a template.
func SendAmpListItems ¶
func SendAmpListItems(w http.ResponseWriter, data ...interface{})
func SendJsonError ¶
func SendJsonError(w http.ResponseWriter, code int, data interface{})
func SendJsonFile ¶
func SendJsonFile(w http.ResponseWriter, filePath string)
func SendJsonResponse ¶
func SendJsonResponse(w http.ResponseWriter, data interface{})
func SetContentTypeJson ¶
func SetContentTypeJson(w http.ResponseWriter)
func SetDefaultMaxAge ¶
func SetDefaultMaxAge(w http.ResponseWriter)
func SetMaxAge ¶
func SetMaxAge(w http.ResponseWriter, age int)
Types ¶
type AccessData ¶
type AccessData struct {
ReturnURL string
}
type AmpListResponse ¶
type AmpListResponse struct {
Items PagedResponse `json:"items"`
}
func GeneratePagedResponse ¶
func GeneratePagedResponse(page int) AmpListResponse
type ArticleBody ¶
type ArticleBody struct {
Type string `json:"@type"`
}
type AuthorizationResponse ¶
type AuthorizationResponse interface {
CreateAuthorizationResponse() AuthorizationResponse
}
type BlogPosting ¶
type BlogPosting struct { Type string `json:"@type"` Headline string `json:"headline"` URL string `json:"url"` DatePublished string `json:"datePublished"` Author Author `json:"author"` BlogArticleBody ArticleBody `json:"articleBody"` BlogPublisher Publisher `json:"publisher"` BlogImage Image `json:"image"` }
type ByPriceAsc ¶
type ByPriceAsc []Product
func (ByPriceAsc) Len ¶
func (a ByPriceAsc) Len() int
func (ByPriceAsc) Less ¶
func (a ByPriceAsc) Less(i, j int) bool
func (ByPriceAsc) Swap ¶
func (a ByPriceAsc) Swap(i, j int)
type ByPriceDesc ¶
type ByPriceDesc []Product
func (ByPriceDesc) Len ¶
func (a ByPriceDesc) Len() int
func (ByPriceDesc) Less ¶
func (a ByPriceDesc) Less(i, j int) bool
func (ByPriceDesc) Swap ¶
func (a ByPriceDesc) Swap(i, j int)
type ClientId ¶
type ClientId struct {
// contains filtered or unexported fields
}
holds a boolean value used for storing the ClientId
type HotelAuthorizationResponse ¶
type HotelAuthorizationResponse struct { User string `json:"username"` Status string `json:"status"` Freenights int `json:"freenights"` }
func (HotelAuthorizationResponse) CreateAuthorizationResponse ¶
func (h HotelAuthorizationResponse) CreateAuthorizationResponse() AuthorizationResponse
type LRUCache ¶
type LRUCache struct { MaxEntries int // contains filtered or unexported fields }
func NewLRUCache ¶
func (*LRUCache) RemoveOldest ¶
func (c *LRUCache) RemoveOldest()
type LiveBlogSample ¶
type PagedResponse ¶
type PagedResponse struct { CurrentPage int `json:"currentPage"` PageCount int `json:"pageCount"` Products []ProductListing `json:"products"` }
type Poll ¶
type Poll struct {
PollAnswers []int
}
holds stored Poll, PollAnswers is an array where index is the question and the value is the vote count
type PollAnswer ¶
holds an answer and votes, used for storing
type PollEntryResult ¶
holds an answers and votes represented as an array, used for displaying
type PollForm ¶
holds the answer chosen by the user and the client id, used for storing data coming from the UI
type PollResult ¶
type PollResult struct { PollEntryResults []PollEntryResult Message string }
holds the poll results and a message, used for displaying
type Product ¶
type Product struct { Id int `json:"id"` Img string `json:"img"` Name string `json:"name"` Price string `json:"price"` Stars string `json:"stars"` Attribution string `json:"attribution"` Url string `json:"url"` Color string `json:"color"` }
func (*Product) StarsAsHtml ¶
type ProductBrowsePage ¶
type ProductListing ¶
type ProductPage ¶
type ProductPage struct {
Mode string
}
type SeatJsonRoot ¶
Source Files ¶
- amp-access.go
- amp-analytics.go
- amp-cache.go
- amp-consent.go
- amp-form.go
- amp-inputmask.go
- amp-live-list.go
- amp-story-auto-ads.go
- amphtml-email.go
- autosuggest.go
- checkout.go
- comment-section.go
- config.go
- echo.go
- favorite.go
- form.go
- hotel.go
- housing.go
- lru-cache.go
- oauth.go
- packager.go
- paged-list.go
- poll.go
- product-browse.go
- rating.go
- redirects.go
- request.go
- seatmap.go
- slow-response.go
- static.go
- template.go
- time.go