当前位置: 首页>>代码示例>>Golang>>正文


Golang appengine.DefaultVersionHostname函数代码示例

本文整理汇总了Golang中appengine.DefaultVersionHostname函数的典型用法代码示例。如果您正苦于以下问题:Golang DefaultVersionHostname函数的具体用法?Golang DefaultVersionHostname怎么用?Golang DefaultVersionHostname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DefaultVersionHostname函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: realhostname

func realhostname(req *http.Request, c appengine.Context) (string, error) {
	if req.RequestURI == "" {
		return appengine.DefaultVersionHostname(c), nil
	}
	myurl, err := url.Parse(req.RequestURI)
	if err != nil {
		return "", err
	}
	if !myurl.IsAbs() {
		return appengine.DefaultVersionHostname(c), nil
	}
	return myurl.Host, nil
}
开发者ID:wickedchicken,项目名称:blarg,代码行数:13,代码来源:layout.go

示例2: realInit

func realInit(w http.ResponseWriter, r *http.Request) bool {
	ctx := appengine.NewContext(r)

	errf := func(format string, args ...interface{}) bool {
		ctx.Errorf("In init: "+format, args...)
		http.Error(w, fmt.Sprintf(format, args...), 500)
		return false
	}

	config, err := serverconfig.Load("./config.json")
	if err != nil {
		return errf("Could not load server config: %v", err)
	}

	// Update the config to use the URL path derived from the first App Engine request.
	// TODO(bslatkin): Support hostnames that aren't x.appspot.com
	scheme := "http"
	if r.TLS != nil {
		scheme = "https"
	}

	baseURL := fmt.Sprintf("%s://%s/", scheme, appengine.DefaultVersionHostname(ctx))
	ctx.Infof("baseurl = %q", baseURL)

	root.mux = http.NewServeMux()
	_, err = config.InstallHandlers(root.mux, baseURL, r)
	if err != nil {
		return errf("Error installing handlers: %v", err)
	}

	return true
}
开发者ID:newobject,项目名称:camlistore,代码行数:32,代码来源:main.go

示例3: aboutPage

func aboutPage(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	fmt.Fprintf(w, "<h1>%v</h1>", appengine.DefaultVersionHostname(c))

	token, expire, _ := appengine.AccessToken(c, "test")
	fmt.Fprintf(w, "<p>AccessToken: %v %v", token, expire)

	fmt.Fprintf(w, "<p>AppID: %v", appengine.AppID(c))
	fmt.Fprintf(w, "<p>FQAppID: %v", c.FullyQualifiedAppID())
	fmt.Fprintf(w, "<p>Go version: %v", runtime.Version())
	fmt.Fprintf(w, "<p>Datacenter: %v", appengine.Datacenter())
	fmt.Fprintf(w, "<p>InstanceID: %v", appengine.InstanceID())
	fmt.Fprintf(w, "<p>IsDevAppServer: %v", appengine.IsDevAppServer())
	fmt.Fprintf(w, "<p>RequestID: %v", appengine.RequestID(c))
	fmt.Fprintf(w, "<p>ServerSoftware: %v", appengine.ServerSoftware())

	sa, _ := appengine.ServiceAccount(c)
	fmt.Fprintf(w, "<p>ServiceAccount: %v", sa)

	keyname, signed, _ := appengine.SignBytes(c, []byte("test"))
	fmt.Fprintf(w, "<p>SignBytes: %v %v", keyname, signed)
	fmt.Fprintf(w, "<p>VersionID: %v", appengine.VersionID(c))

	fmt.Fprintf(w, "<p>Request: %v", r)
	r2 := c.Request()
	fmt.Fprintf(w, "<p>Context Request type/value: %T %v", r2, r2)
}
开发者ID:jmptrader,项目名称:jra-go,代码行数:27,代码来源:appengine.go

示例4: Presentation

//Presentation handles showing page with details about a presentation.
func Presentation(c util.Context) (err error) {
	pk, err := datastore.DecodeKey(c.Vars["id"])
	if err != nil {
		return
	}

	p, err := presentation.GetByKey(pk, c)
	if err != nil {
		return
	}
	as, err := action.GetFor(p, c)
	if err != nil {
		return
	}

	a := prepareActions(as)

	desc := blackfriday.MarkdownCommon(p.Description)

	acts, err := activation.GetForPresentation(pk, c)
	if err != nil {
		return
	}

	util.RenderLayout("presentation.html", "Info o prezentácií", struct {
		P           *presentation.Presentation
		A           map[string][]time.Time
		Desc        template.HTML
		ZeroTime    time.Time
		Domain      string
		Activations []*activation.Activation
		Tz          *time.Location
	}{p, a, template.HTML(desc), time.Date(0001, 01, 01, 00, 00, 00, 00, utc), appengine.DefaultVersionHostname(c), acts, util.Tz}, c, "/static/js/underscore-min.js", "/static/js/presentation.js")
	return
}
开发者ID:sellweek,项目名称:TOGY-server,代码行数:36,代码来源:broadcast.go

示例5: send

// send uses the Channel API to send the provided message in JSON-encoded form
// to the client identified by clientID.
//
// Channels created with one version of an app (eg, the default frontend)
// cannot be sent on from another version (eg, a backend). This is a limitation
// of the Channel API that should be fixed at some point.
// The send function creates a task that runs on the frontend (where the
// channel was created). The task handler makes the channel.Send API call.
func send(c appengine.Context, clientID string, m Message) {
	if clientID == "" {
		c.Debugf("no channel; skipping message send")
		return
	}
	switch {
	case m.TilesDone:
		c.Debugf("tiles done")
	case m.ZipDone:
		c.Debugf("zip done")
	default:
		c.Debugf("%d tiles", len(m.IDs))
	}
	b, err := json.Marshal(m)
	if err != nil {
		panic(err)
	}
	task := taskqueue.NewPOSTTask("/send", url.Values{
		"clientID": {clientID},
		"msg":      {string(b)},
	})
	host := appengine.DefaultVersionHostname(c)
	task.Header.Set("Host", host)
	if _, err := taskqueue.Add(c, task, sendQueue); err != nil {
		c.Errorf("add send task failed: %v", err)
	}
}
开发者ID:TheAustrianPro,项目名称:overlay-tiler,代码行数:35,代码来源:task.go

示例6: handler

func handler(w http.ResponseWriter, r *http.Request) {
	img_url := r.FormValue("me")

	if len(img_url) == 0 {
		http.Redirect(w, r, "/index.html", 307)
		return
	}

	c := appengine.NewContext(r)

	c.Infof("Host: %v", appengine.DefaultVersionHostname(c))

	item, err := getCached(c, img_url, do)

	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	w.Header().Set("Content-Type", "image/jpeg")
	w.Header().Set("Content-Length", strconv.Itoa(len(item.Value)))
	if _, err := w.Write(item.Value); err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
	}
}
开发者ID:coel,项目名称:greenyfy,代码行数:25,代码来源:greenyfy.go

示例7: CreateUrls

func (fi *FileInfo) CreateUrls(r *http.Request, c appengine.Context) {
	u := &url.URL{
		Scheme: r.URL.Scheme,
		Host:   appengine.DefaultVersionHostname(c),
		Path:   "/",
	}
	uString := u.String()
	fi.Url = uString + escape(string(fi.Key)) + "/" +
		escape(string(fi.Name))
	fi.DeleteUrl = fi.Url + "?delete=true"
	fi.DeleteType = "DELETE"
	if imageTypes.MatchString(fi.Type) {
		servingUrl, err := image.ServingURL(
			c,
			fi.Key,
			&image.ServingURLOptions{
				Secure: strings.HasSuffix(u.Scheme, "s"),
				Size:   0,
				Crop:   false,
			},
		)
		check(err)
		fi.ThumbnailUrl = servingUrl.String() + THUMBNAIL_PARAM
	}
}
开发者ID:omairrazam,项目名称:bapp,代码行数:25,代码来源:main.go

示例8: cron

func cron(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	q := datastore.NewQuery("asin")

	for t := q.Run(c); ; {
		var x Asin
		_, err := t.Next(&x)
		if err == datastore.Done {
			break
		}
		if err != nil {
			return
		}

		task := taskqueue.NewPOSTTask("/task/fetching", url.Values{
			"asin": {x.Name},
		})

		if !appengine.IsDevAppServer() {
			host := backendName + "." + appengine.DefaultVersionHostname(c)
			task.Header.Set("Host", host)
		}

		if _, err := taskqueue.Add(c, task, ""); err != nil {
			c.Errorf("add fetching task: %v", err)
			http.Error(w, "Error: couldn't schedule fetching task", 500)
			return
		}

		fmt.Fprintf(w, "OK")
	}
}
开发者ID:moonpala,项目名称:snapshot,代码行数:32,代码来源:frontend.go

示例9: handler

func handler(w http.ResponseWriter, r *http.Request) {
	context := appengine.NewContext(r)

	err := parse_chunk_map(context)

	if err != nil {
		log.Fatal("error:", err)
	} else {
		// Determine which file is being requested then construct cached version
		// by collecting the chunks together into one big download.

		w.Header().Set("Content-Type", "application/json")

		var chunkMapWithUrls map[string][]ChunkEntry = make(map[string][]ChunkEntry)

		bigFilename := r.URL.Path

		if len(bigFilename) == 0 {
			log.Fatal(fmt.Sprintf("path \"%s\"", bigFilename))
		} else if bigFilename[0] != '/' {
			log.Fatal(fmt.Sprintf("path \"%s\"", bigFilename))
		} else if strings.Count(bigFilename, "/") != 1 {
			log.Fatal(fmt.Sprintf("path \"%s\"", bigFilename))
		}

		bigFilename = bigFilename[1:]
		chunkArr := chunkMap[bigFilename]

		{
			var chunks []ChunkEntry = make([]ChunkEntry, len(chunkArr))

			for i, chunkEntry := range chunkArr {
				chunks[i] = chunkEntry
				chunks[i].ChunkName = fmt.Sprintf("%s%s/chunk/%s", "http://", appengine.DefaultVersionHostname(context), chunkEntry.ChunkName)
			}

			chunkMapWithUrls[bigFilename] = chunks
		}

		bytes, err := json.MarshalIndent(chunkMapWithUrls, "", "  ")
		if err != nil {
			log.Fatal("error:", err)
		}

		bytes = append(bytes, '\n')

		_, err = w.Write(bytes)
		if err != nil {
			log.Fatal("error:", err)
		}
	}
}
开发者ID:carriercomm,项目名称:GoFreeCDN,代码行数:52,代码来源:servefile.go

示例10: CreateUrls

func (fi *FileInfo) CreateUrls(r *http.Request, c appengine.Context) {
	u := &url.URL{
		Scheme: r.URL.Scheme,
		Host:   appengine.DefaultVersionHostname(c),
		Path:   "/",
	}
	uString := u.String()
	fi.Url = uString + fi.Key
	fi.DeleteUrl = fi.Url
	fi.DeleteType = "DELETE"
	if fi.ThumbnailKey != "" {
		fi.ThumbnailUrl = uString + fi.ThumbnailKey
	}
}
开发者ID:devCPXL,项目名称:gestion_stock_old,代码行数:14,代码来源:main.go

示例11: Presentations

//Presentations shows listing of presentations in paginated form.
func Presentations(c util.Context) (err error) {
	page, err := strconv.Atoi(c.R.FormValue("p"))
	if err != nil {
		return
	}
	ps, err := presentation.GetListing(page, perPage, c)
	if err != nil {
		return
	}

	type templateData struct {
		P presentation.Presentation
		D template.HTML
	}

	data := make([]templateData, len(ps), len(ps))

	for _, p := range ps {
		data = append(data, templateData{P: *p, D: template.HTML(blackfriday.MarkdownCommon(p.Description))})
	}

	maxPages, err := presentation.PageCount(perPage, c)
	if err != nil {
		return
	}

	c.Infof("Hostname: %v", appengine.DefaultVersionHostname(c))

	util.RenderLayout("index.html", "Zoznam vysielaní", struct {
		Page     int
		MaxPages int
		Data     []templateData
		Domain   string
	}{Page: page, MaxPages: maxPages, Data: data, Domain: appengine.DefaultVersionHostname(c)}, c, "/static/js/index.js")
	return
}
开发者ID:sellweek,项目名称:TOGY-server,代码行数:37,代码来源:public.go

示例12: getBeardFromUrl

func getBeardFromUrl(c appengine.Context, key string) (*bytes.Buffer, error) {
	client := urlfetch.Client(c)
	resp, err := client.Get("http://" + appengine.DefaultVersionHostname(c) + "/images/beard.png")

	if err != nil {
		return nil, err
	}

	defer resp.Body.Close()

	buff := new(bytes.Buffer)
	buff.ReadFrom(resp.Body)

	return buff, nil
}
开发者ID:coel,项目名称:greenyfy,代码行数:15,代码来源:beard.go

示例13: CreateUrls

func (fi *FileInfo) CreateUrls(r *http.Request, c appengine.Context) {
	u := &url.URL{
		Scheme: r.URL.Scheme,
		Host:   appengine.DefaultVersionHostname(c),
	}
	u.Path = "/" + url.QueryEscape(string(fi.Key)) + "/" +
		url.QueryEscape(string(fi.Name))
	fi.Url = u.String()
	fi.DeleteUrl = fi.Url
	fi.DeleteType = "DELETE"
	if fi.ThumbnailUrl != "" && -1 == strings.Index(
		r.Header.Get("Accept"),
		"application/json",
	) {
		u.Path = "/thumbnails/" + url.QueryEscape(string(fi.Key))
		fi.ThumbnailUrl = u.String()
	}
}
开发者ID:steliomo,项目名称:jQuery-File-Upload,代码行数:18,代码来源:main.go

示例14: handler

func handler(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "text/html; charset=utf-8")
	fmt.Fprintf(w, "<!DOCTYPE html>")
	fmt.Fprintf(w, "<html><head><title>appengineパッケージ</title></head><body>")

	if appengine.IsDevAppServer() {
		// 開発環境
		fmt.Fprintf(w, "開発環境で動作しています。。<br>")
	} else {
		fmt.Fprintf(w, "本番環境で動作しています。<br>")
	}

	c := appengine.NewContext(r)

	fmt.Fprintf(w, "AppID(): %s<br>", appengine.AppID(c))
	fmt.Fprintf(w, "DefaultVersionHostname(): %s<br>", appengine.DefaultVersionHostname(c))

	fmt.Fprintf(w, "VersionID(): %s<br>", appengine.VersionID(c))
	fmt.Fprintf(w, "</body></html>")
}
开发者ID:ghostnotes,项目名称:HelloGo,代码行数:20,代码来源:appenginesample.go

示例15: homeHandler

func homeHandler(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)

	data := map[string]string{
		"isDevelopment":   appEngineEnvironment("isDevelopment"),
		"isProduction":    appEngineEnvironment("isProduction"),
		"currentHostname": appengine.DefaultVersionHostname(c),
	}

	tpl, err := ace.Load("base", "inner", &ace.Options{
		BaseDir:       "views",
		DynamicReload: true})
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	if err := tpl.Execute(w, data); err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
}
开发者ID:aficiomaquinas,项目名称:i18n-cd-mx,代码行数:22,代码来源:server.go


注:本文中的appengine.DefaultVersionHostname函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。