英文:
specifying type of content in rest.Resource (rest.go lib & Golang)
问题
我写了一个json数据结构,并将其存储在URL中作为资源。
type FileString struct {
Data string
}
rest.Resource("json_data", &FileString{Data: some_string})
但是当我将其作为uri加载到java-script中时,
loader.load({ model: '/json_data/', callback: function (geometry) {
...
}
我在js控制台中得到了以下错误信息:
> 'Resource interpreted as Script but transferred with MIME type text/html.'
在执行rest.Resource(...)
时,我应该在哪里设置内容类型?请帮忙。
英文:
I write a json data structure,
and store it in the url as a resource
type FileString struct {
Data string
}
rest.Resource("json_data", &FileString{Data : some_string})
but when I load it in the java-script, as a uri
loader.load( { model: '/json_data/', callback: function ( geometry ) {
...
}
I get in the js console
>'Resource interpreted as Script but transferred with MIME type text/html.'
Where do I set the content type when doing rest.Resource(...)
???
Please Help.
答案1
得分: 1
你不能。rest.go不公开该功能。你可以向开发者提交一个问题。
英文:
You can't. rest.go doesn't expose that functionality.
You could file an issue with the developer.
答案2
得分: 1
Goweb的API部分提供了更多对底层HTTP的控制,允许您以通常的方式指定内容类型。
英文:
Goweb's API stuff provides much more control over the underlying HTTP allowing you to specify content type in the usual way.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论