本文整理匯總了Golang中appengine.IsDevAppServer函數的典型用法代碼示例。如果您正苦於以下問題:Golang IsDevAppServer函數的具體用法?Golang IsDevAppServer怎麽用?Golang IsDevAppServer使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了IsDevAppServer函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
func init() {
angular_ver := "1.0.7"
bootstrap_ver := "2.3.2"
font_awesome_ver := "3.2.1"
jquery_ver := "1.9.1"
jqueryui_ver := "1.10.3"
underscore_ver := "1.4.4"
isDevServer = appengine.IsDevAppServer()
if appengine.IsDevAppServer() {
Angular = fmt.Sprintf("/static/js/angular-%v.js", angular_ver)
BootstrapCss = fmt.Sprintf("/static/css/bootstrap-combined-no-icons-%v.css", bootstrap_ver)
BootstrapJs = fmt.Sprintf("/static/js/bootstrap-%v.js", bootstrap_ver)
FontAwesome = fmt.Sprintf("/static/css/font-awesome-%v.css", font_awesome_ver)
Jquery = fmt.Sprintf("/static/js/jquery-%v.js", jquery_ver)
JqueryUI = fmt.Sprintf("/static/js/jquery-ui-%v.js", jqueryui_ver)
Underscore = fmt.Sprintf("/static/js/underscore-%v.js", underscore_ver)
} else {
Angular = fmt.Sprintf("//ajax.googleapis.com/ajax/libs/angularjs/%v/angular.min.js", angular_ver)
BootstrapCss = fmt.Sprintf("//netdna.bootstrapcdn.com/twitter-bootstrap/%v/css/bootstrap-combined.no-icons.min.css", bootstrap_ver)
BootstrapJs = fmt.Sprintf("//netdna.bootstrapcdn.com/twitter-bootstrap/%v/js/bootstrap.min.js", bootstrap_ver)
FontAwesome = fmt.Sprintf("//netdna.bootstrapcdn.com/font-awesome/%v/css/font-awesome.min.css", font_awesome_ver)
Jquery = fmt.Sprintf("//ajax.googleapis.com/ajax/libs/jquery/%v/jquery.min.js", jquery_ver)
JqueryUI = fmt.Sprintf("//ajax.googleapis.com/ajax/libs/jqueryui/%v/jquery-ui.min.js", jqueryui_ver)
Underscore = fmt.Sprintf("/static/js/underscore-%v.min.js", underscore_ver)
}
}
示例2: init
func init() {
angular_ver := "1.0.5"
bootstrap_ver := "2.3.2"
jquery_ver := "1.9.1"
jqueryui_ver := "1.10.3"
underscore_ver := "1.4.4"
isDevServer = appengine.IsDevAppServer()
if appengine.IsDevAppServer() {
Angular = fmt.Sprintf("/static/js/angular-%v.js", angular_ver)
BootstrapCss = fmt.Sprintf("/static/css/bootstrap-combined-%v.css", bootstrap_ver)
BootstrapJs = fmt.Sprintf("/static/js/bootstrap-%v.js", bootstrap_ver)
Jquery = fmt.Sprintf("/static/js/jquery-%v.js", jquery_ver)
JqueryUI = fmt.Sprintf("/static/js/jquery-ui-%v.js", jqueryui_ver)
SiteStyleCss = "/static/css/styles.css"
Underscore = fmt.Sprintf("/static/js/underscore-%v.js", underscore_ver)
} else {
Angular = fmt.Sprintf("//ajax.googleapis.com/ajax/libs/angularjs/%v/angular.min.js", angular_ver)
BootstrapCss = fmt.Sprintf("//netdna.bootstrapcdn.com/twitter-bootstrap/%v/css/bootstrap-combined.min.css", bootstrap_ver)
BootstrapJs = fmt.Sprintf("//netdna.bootstrapcdn.com/twitter-bootstrap/%v/js/bootstrap.min.js", bootstrap_ver)
Jquery = fmt.Sprintf("//ajax.googleapis.com/ajax/libs/jquery/%v/jquery.min.js", jquery_ver)
JqueryUI = fmt.Sprintf("//ajax.googleapis.com/ajax/libs/jqueryui/%v/jquery-ui.min.js", jqueryui_ver)
SiteStyleCss = "/static/css/styles.css"
Underscore = fmt.Sprintf("/static/js/underscore-%v.min.js", underscore_ver)
}
}
示例3: init
func init() {
angular_ver := "1.2.1"
bootstrap_ver := "3.0.2"
font_awesome_ver := "4.0.3"
jquery_ver := "2.0.3"
jqueryui_ver := "1.10.3.sortable"
isDevServer = appengine.IsDevAppServer()
if appengine.IsDevAppServer() {
Angular = "/static/js/angular.js"
BootstrapCss = "/static/css/bootstrap.css"
BootstrapJs = "/static/js/bootstrap.js"
FontAwesome = "/static/css/font-awesome.css"
Jquery = fmt.Sprintf("/static/js/jquery-%v.js", jquery_ver)
JqueryUI = fmt.Sprintf("/static/js/jquery-ui-%v.js", jqueryui_ver)
Underscore = "/static/js/underscore.js"
} else {
Angular = fmt.Sprintf("//ajax.googleapis.com/ajax/libs/angularjs/%v/angular.min.js", angular_ver)
BootstrapCss = fmt.Sprintf("//netdna.bootstrapcdn.com/bootstrap/%v/css/bootstrap.min.css", bootstrap_ver)
BootstrapJs = fmt.Sprintf("//netdna.bootstrapcdn.com/bootstrap/%v/js/bootstrap.min.js", bootstrap_ver)
FontAwesome = fmt.Sprintf("//netdna.bootstrapcdn.com/font-awesome/%v/css/font-awesome.min.css", font_awesome_ver)
Jquery = fmt.Sprintf("//ajax.googleapis.com/ajax/libs/jquery/%v/jquery.min.js", jquery_ver)
JqueryUI = fmt.Sprintf("/static/js/jquery-ui-%v.min.js", jqueryui_ver)
Underscore = "/static/js/underscore-min.js"
}
}
示例4: hash
func hash(path string) string {
hashmutex.Lock()
defer hashmutex.Unlock()
if !appengine.IsDevAppServer() {
if cached, ok := hashcache[path]; ok {
return cached
}
}
b, e := ioutil.ReadFile(path)
if e != nil {
panic(e)
}
sha := sha256.New()
sha.Write(b)
sum := sha.Sum(nil)
hash := hex.EncodeToString(sum)
hashcache[path] = hash
return hash
}
示例5: newStorageService
// Creates a new Google Cloud Storage Client
func newStorageService(c appengine.Context) (*storage.Service, error) {
var httpClient *http.Client
var err error
if appengine.IsDevAppServer() {
httpClient, err = devserviceaccount.NewClient(c, devStorageKeyPath, scope)
} else {
httpClient, err = serviceaccount.NewClient(c, scope)
}
if err != nil {
return nil, err
}
service, err := storage.New(httpClient)
if err != nil {
return nil, err
}
if err = initDefaultBucket(service); err != nil {
return nil, err
}
return service, nil
}
示例6: AppstatsHandler
func AppstatsHandler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
if appengine.IsDevAppServer() {
// noop
} else if u := user.Current(c); u == nil {
if loginURL, err := user.LoginURL(c, r.URL.String()); err == nil {
http.Redirect(w, r, loginURL, http.StatusTemporaryRedirect)
} else {
serveError(w, err)
}
return
} else if !u.Admin {
http.Error(w, "Forbidden", http.StatusForbidden)
return
}
if detailsURL == r.URL.Path {
Details(w, r)
} else if fileURL == r.URL.Path {
File(w, r)
} else if strings.HasPrefix(r.URL.Path, staticURL) {
Static(w, r)
} else {
Index(w, r)
}
}
示例7: ExecTemplate
func ExecTemplate(c *TemplateConfig) error {
cname := ""
for i, name := range c.Names {
c.Names[i] = filepath.Join(c.Dir, name+".html")
cname += name
}
templatesMutex.Lock()
defer templatesMutex.Unlock()
t, ok := templatesCache[cname]
if !ok || appengine.IsDevAppServer() {
var err error
t, err = template.New(cname).ParseFiles(c.Names...)
if err != nil {
return fmt.Errorf("templates parsing failed: %s", err)
}
templatesCache[cname] = t
}
if err := t.ExecuteTemplate(c.W, "base", c.Data); err != nil {
return fmt.Errorf("exec templates failed: %s", err)
}
return nil
}
示例8: init
func init() {
http.HandleFunc("/", frontPageHandler)
http.HandleFunc("/tiles", tileHandler)
for i := range color {
// Use a broader range of color for low intensities.
if i < 255/10 {
color[i] = image.RGBAColor{uint8(i * 10), 0, 0, 0xFF}
} else {
color[i] = image.RGBAColor{0xFF, 0, uint8(i - 255/10), 0xFF}
}
}
tmpl := template.New(nil)
tmpl.SetDelims("{{", "}}")
if err := tmpl.ParseFile("map.html"); err != nil {
frontPage = []byte("tmpl.ParseFile failed: " + err.String())
return
}
b := new(bytes.Buffer)
data := map[string]interface{}{
"InProd": !appengine.IsDevAppServer(),
}
if err := tmpl.Execute(b, data); err != nil {
frontPage = []byte("tmpl.Execute failed: " + err.String())
return
}
frontPage = b.Bytes()
}
示例9: wrapHandler
func wrapHandler(f func(w http.ResponseWriter, r *http.Request) error) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// pre ops:
// - setup response
front_origin := ""
if appengine.IsDevAppServer() {
front_origin = "http://127.0.0.1:9000"
} else {
front_origin = "http://pgu-geo-ng.appspot.com"
}
w.Header().Set("Access-Control-Allow-Origin", front_origin)
w.Header().Set("Content-Type", "application/json")
// execute handler
err := f(w, r)
// post ops
// - handle an error
if err == nil {
return
}
switch err.(type) {
case badRequest:
http.Error(w, err.Error(), http.StatusBadRequest)
case notFound:
http.Error(w, "entity not found", http.StatusNotFound)
default:
log.Println(err)
http.Error(w, "oops", http.StatusInternalServerError)
}
}
}
示例10: ExecTemplate
func ExecTemplate(c *TemplateConfig) error {
templatesMutex.Lock()
defer templatesMutex.Unlock()
cname := ""
for i, name := range c.Names {
c.Names[i] = filepath.Join(c.Dir, name+".html")
cname += name
}
t, ok := templatesCache[cname]
if !ok || appengine.IsDevAppServer() {
var err error
t = template.New(cname).Delims(c.LeftDelim, c.RightDelim)
t, err = t.Funcs(templatesFuncs).ParseFiles(c.Names...)
if err != nil {
return errors.New(err)
}
templatesCache[cname] = t
}
if err := t.ExecuteTemplate(c.W, "base", c.Data); err != nil {
return errors.New(err)
}
return nil
}
示例11: init
func init() {
page.DevCssFiles = []string{
"reset.css",
"general.css",
"form.css",
"subreddit-picker.css",
"board.css",
"board-item.css",
}
page.CompiledCssFile = "1uePdv.css"
page.CompiledJsFile = "1vkcJu.js"
page.IsDevAppServer = appengine.IsDevAppServer()
var err error
if cachedTemplate, err = loadTemplate(); err != nil {
http.HandleFunc("/", handleInitError(err))
return
}
http.HandleFunc("/", handleRequest)
// The most requested URL that doesn't exist anymore. Handling it outside of
// handleRequest avoids expensive RegEx testing that is going on in
// handleRequest.
http.HandleFunc("/feeds/atom/", handleFeedRequest)
}
示例12: CheckForAdminUser
func CheckForAdminUser(r *http.Request) (bool, *user.User, string) {
if appengine.IsDevAppServer() {
return true, &user.User{Email: "[email protected]", Admin: true, ID: "32168"}, "DevServer login granted"
}
u, msg := UserFromReq(r)
if u == nil {
msg = "google appengine oauth required - admin rights - no login found \n" + msg
msg = "use /appengine/login\n" + msg
return false, nil, msg
}
if u != nil && !u.Admin {
msg = "google appengine oauth required - admin rights - login found without admin \n" + msg
msg = "use /appengine/login\n" + msg
return false, nil, msg
}
// if u.ID != "108853175242330402880" && u.ID != "S-1-5-21-2175189548-897864986-1736798499-1000" {
// }
return true, u, msg
}
示例13: WrapHandlerImpl
// Wraps other http handlers. Creates context object, recovers from panics, etc.
func WrapHandlerImpl(fn AppHandlerFunc, parseForm bool) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
c := &Context{}
// See http://blog.golang.org/2010/08/defer-panic-and-recover.html.
defer func() {
if data := recover(); data != nil {
c.Aec().Errorf(fmt.Sprint(data))
ServeError(w, data)
}
}()
// Initialize the request context object.
c.SetAec(appengine.NewContext(r))
CheckError(ReadSession(r, c))
if msg, err := ConsumeFlash(w, r); err != nil && err != http.ErrNoCookie {
ServeError(w, err)
return
} else {
c.SetFlash(msg)
}
if parseForm {
CheckError(r.ParseForm())
}
if appengine.IsDevAppServer() {
tmpl = template.Must(template.ParseGlob("templates/*.html"))
text_tmpl = text_template.Must(text_template.ParseGlob("templates/*.txt"))
}
fn(w, r, c)
}
}
示例14: init
func init() {
var err error
local, err = time.LoadLocation("America/New_York")
if err != nil {
panic(err)
}
http.Handle("/", webapp.Router)
webapp.HandleFunc("/", index)
webapp.HandleFunc("/class", class)
webapp.Handle("/roster", userContextHandler(webapp.HandlerFunc(roster)))
if appengine.IsDevAppServer() {
webapp.HandleFunc("/error", throwError)
}
for url, template := range map[string]string{
"/about": "templates/about.html",
"/pricing": "templates/pricing.html",
"/privates-groups": "templates/privates-groups.html",
"/teachers": "templates/teachers.html",
"/workshops": "templates/workshops.html",
"/mailinglist": "templates/mailinglist.html",
} {
webapp.HandleFunc(url, staticTemplate(template))
}
}
示例15: init
func init() {
if appengine.IsDevAppServer() {
ContextFactory = tokeninfoContextFactory
} else {
ContextFactory = cachingContextFactory
}
}