开发者

specifying type of content in rest.Resource (rest.go lib & Golang)

开发者 https://www.devze.com 2023-03-20 23:05 出处:网络
I write a json data structure, and store it in the url as a resource type FileString struct { Data string

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.


You can't. rest.go doesn't expose that functionality. You could file an issue with the developer.


Goweb's API stuff provides much more control over the underlying HTTP allowing you to specify content type in the usual way.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号