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


Golang mime.AddExtensionType函数代码示例

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


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

示例1: init

func init() {
	// Silence log output
	log.SetOutput(nil)

	// setup mime
	mime.AddExtensionType(".foo", "foo/bar")
	mime.AddExtensionType(".json", "application/json")
	mime.AddExtensionType(".txt", "text/plain")
	mime.AddExtensionType(".png", "image/png")
	mime.AddExtensionType(".html", "text/html")

	go func() {

		// falcore setup
		pipeline := falcore.NewPipeline()
		pipeline.Upstream.PushBack(&FileFilter{
			PathPrefix:     "/",
			BasePath:       "../test/",
			DirectoryIndex: "index.html",
		})
		srv = falcore.NewServer(0, pipeline)
		if err := srv.ListenAndServe(); err != nil {
			panic(fmt.Sprintf("Could not start falcore: %v", err))
		}
	}()
}
开发者ID:dcmrlee,项目名称:falcore,代码行数:26,代码来源:file_filter_test.go

示例2: init

func init() {
	if err := mime.AddExtensionType(".rmvb", "application/vnd.rn-realmedia-vbr"); err != nil {
		panic(err)
	}
	if err := mime.AddExtensionType(".ogv", "video/ogg"); err != nil {
		panic(err)
	}
}
开发者ID:ronindev,项目名称:dms,代码行数:8,代码来源:dms.go

示例3: main

func main() {
	//	beego.AutoRender = false
	beego.ViewsPath = "tpl" //模板存储目录
	beego.SessionOn = true  //SESSION开启

	mime.AddExtensionType(".css", "text/css")              //CSS 输出页头Content-Type
	mime.AddExtensionType(".js", "application/javascript") //JS 输出页头Content-Type
	beego.SetStaticPath("/static", "static")               //注册静态文件目录
	beego.Errorhandler("404", page404)
	beego.Run()
}
开发者ID:wuxinchaliu,项目名称:go-workadmin,代码行数:11,代码来源:main.go

示例4: init

func init() {
	// Add some types we want to be able to handle which can be missing by default
	mime.AddExtensionType(".json", "application/json")
	mime.AddExtensionType(".yml", "application/yaml")
	mime.AddExtensionType(".yaml", "application/yaml")

	sourceReaders = make(map[string]func(*Source) ([]byte, error))

	// Register our source-reader functions
	addSourceReader("http", readHTTP)
	addSourceReader("https", readHTTP)
	addSourceReader("file", readFile)
}
开发者ID:hairyhenderson,项目名称:gomplate,代码行数:13,代码来源:data.go

示例5: initServer

func (s *Server) initServer() {
	if s.Config == nil {
		s.Config = &ServerConfig{}
	}

	if s.Logger == nil {
		s.Logger = log.New(os.Stdout, "", log.Ldate|log.Ltime)
	}
	// Set two commonly used mimetypes that are often not set by default
	// Handy for robots.txt and favicon.ico
	mime.AddExtensionType(".txt", "text/plain; charset=utf-8")
	mime.AddExtensionType(".ico", "image/x-icon")
}
开发者ID:Remo,项目名称:web,代码行数:13,代码来源:web.go

示例6: MimeType

func MimeType(args []string) {
	filename := args[0]
	ext := filepath.Ext(filename)
	mime.AddExtensionType(".gz", "application/gzip")
	mime.AddExtensionType(".tgz", "application/gzip")
	mime.AddExtensionType(".tar", "application/tar")
	mime.AddExtensionType(".zip", "application/zip")
	mimetype := mime.TypeByExtension(ext)
	if mimetype != "" {
		fmt.Println(mimetype)
	} else {
		fmt.Println("application/octet-stream")
	}
}
开发者ID:jimmidyson,项目名称:gh-release,代码行数:14,代码来源:gh-release.go

示例7: start

// Setup all routers, handlers and start a HTTP server (blocking call)
func (api *RESTfulAPI) start(catalogStorage catalog.CatalogStorage) {
	api.mountCatalog(catalogStorage)
	api.mountResources()

	api.router.Methods("GET", "POST").Path("/dashboard").HandlerFunc(api.dashboardHandler(*confPath))
	api.router.Methods("GET").Path(api.restConfig.Location).HandlerFunc(api.indexHandler())

	err := mime.AddExtensionType(".jsonld", "application/ld+json")
	if err != nil {
		logger.Println("RESTfulAPI.start() ERROR:", err.Error())
	}

	// Configure the middleware
	n := negroni.New(
		negroni.NewRecovery(),
		negroni.NewLogger(),
		&negroni.Static{
			Dir:       http.Dir(api.config.StaticDir),
			Prefix:    StaticLocation,
			IndexFile: "index.html",
		},
	)
	// Mount router
	n.UseHandler(api.router)

	// Start the listener
	addr := fmt.Sprintf("%v:%v", api.config.Http.BindAddr, api.config.Http.BindPort)
	logger.Printf("RESTfulAPI.start() Starting server at http://%v%v", addr, api.restConfig.Location)
	n.Run(addr)
}
开发者ID:xunmengfeng,项目名称:patchwork,代码行数:31,代码来源:http.go

示例8: init

func init() {
	// add missing extensions
	for k, v := range mimeRdfExt {
		mime.AddExtensionType(k, v)
	}

	for _, syntax := range crdf.ParserSyntax {
		switch syntax.MimeType {
		case "", "text/html":
			continue
		}
		mimeParser[syntax.MimeType] = syntax.Name
	}
	mimeParser["text/n3"] = mimeParser["text/turtle"]

	for name, syntax := range crdf.SerializerSyntax {
		switch name {
		case "json-triples":
			// only activate: json
			continue
		case "rdfxml-xmp", "rdfxml":
			// only activate: rdfxml-abbrev
			continue
		}
		mimeSerializer[syntax.MimeType] = syntax.Name
	}

	for mime := range mimeSerializer {
		switch mime {
		case "application/xhtml+xml":
			continue
		}
		serializerMimes = append(serializerMimes, mime)
	}
}
开发者ID:peacekeeper,项目名称:debian-gold,代码行数:35,代码来源:mime.go

示例9: Serve

func Serve(httpAddress *string, db core.Database, s *search.Searcher, devAssets bool, updater *torrent.StatsUpdater) {

	// Add SVG to mime directory
	mime.AddExtensionType(".svg", "image/svg+xml")

	r := mux.NewRouter()

	apirouter := ApiRouter(db, s, updater)

	r.PathPrefix("/api/").Handler(apirouter)
	if devAssets {
		log.Println("Debug mode is on. Serving development assets from angular/app.")
		r.PathPrefix("/styles/").Handler(http.FileServer(http.Dir("frontend/angular/.tmp/")))
		r.PathPrefix("/bower_components/").Handler(http.FileServer(http.Dir("frontend/angular/")))
		r.PathPrefix("/").Handler(NotFoundHook{
			http.FileServer(http.Dir("frontend/angular/app/")),
			"frontend/angular/app/index.html"})
	} else {
		r.PathPrefix("/").Handler(NotFoundHook{
			http.FileServer(http.Dir("frontend/angular/dist/")),
			"frontend/angular/dist/index.html"})
	}
	http.Handle("/", r)
	log.Println("Web server listening on", *httpAddress)
	err := http.ListenAndServe(*httpAddress, nil)
	if err != nil {
		log.Println(err)
	}
}
开发者ID:sdgoij,项目名称:TheDistributedBay,代码行数:29,代码来源:frontend.go

示例10: init

func init() {
	playScript(basePath, "HTTPTransport")
	present.PlayEnabled = true

	// App Engine has no /etc/mime.types
	mime.AddExtensionType(".svg", "image/svg+xml")
}
开发者ID:hackrole,项目名称:daily-program,代码行数:7,代码来源:appengine.go

示例11: init

func init() {
	initHugoBuilderFlags(serverCmd)

	serverCmd.Flags().IntVarP(&serverPort, "port", "p", 1313, "port on which the server will listen")
	serverCmd.Flags().StringVarP(&serverInterface, "bind", "", "127.0.0.1", "interface to which the server will bind")
	serverCmd.Flags().BoolVarP(&serverWatch, "watch", "w", true, "watch filesystem for changes and recreate as needed")
	serverCmd.Flags().BoolVarP(&serverAppend, "appendPort", "", true, "append port to baseurl")
	serverCmd.Flags().BoolVar(&disableLiveReload, "disableLiveReload", false, "watch without enabling live browser reload on rebuild")
	serverCmd.Flags().BoolVar(&renderToDisk, "renderToDisk", false, "render to Destination path (default is render to memory & serve from there)")
	serverCmd.Flags().String("memstats", "", "log memory usage to this file")
	serverCmd.Flags().Int("meminterval", 100, "interval to poll memory usage (requires --memstats)")
	serverCmd.RunE = server

	mime.AddExtensionType(".json", "application/json; charset=utf-8")
	mime.AddExtensionType(".css", "text/css; charset=utf-8")

}
开发者ID:vbatoufflet,项目名称:hugo,代码行数:17,代码来源:server.go

示例12: main

func main() {
	mime.AddExtensionType(".ico", "image/x-icon")
	mime.AddExtensionType(".svg", "image/svg+xml")

	fileHandler := http.FileServer(http.Dir("/content"))
	http.Handle("/", loggingHandler(fileHandler))

	go func() {
		log.Println("Starting up at :8080")
		log.Fatal(http.ListenAndServe(":8080", nil))
	}()

	// Handle SIGTERM.
	ch := make(chan os.Signal)
	signal.Notify(ch, syscall.SIGTERM)
	log.Printf("Received signal '%v'. Exiting.", <-ch)
}
开发者ID:amuino,项目名称:helloworld,代码行数:17,代码来源:main.go

示例13: init

func init() {
	initTemplates("./present/")
	present.PlayEnabled = true
	initPlayground("./present/", nil)

	// App Engine has no /etc/mime.types
	mime.AddExtensionType(".svg", "image/svg+xml")
}
开发者ID:ChloeTigre,项目名称:golang-tools,代码行数:8,代码来源:appengine.go

示例14: init

func init() {
	mime.AddExtensionType(".dart", "application/dart")

	fs := http.FileServer(http.Dir("app/build/web"))
	http.Handle("/", fs)
	//router.Run(":8080")
	//http.ListenAndServe(":8080", nil)
}
开发者ID:SimiPro,项目名称:letsgo,代码行数:8,代码来源:serve-client.go

示例15: init

// Register all the mimes in types.go
func init() {
	for _, v := range mimes {
		err := mime.AddExtensionType(v.Extension, v.Type)
		if err != nil {
			log.Println(err)
		}
	}
}
开发者ID:rbns,项目名称:extramime,代码行数:9,代码来源:extramime.go


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