Hello. I'm trying to create HTML api it means server responds HTML tag. Now, I tested simple case. This is my code.
I intend to get only p tag.
but as you can see, HTML has other basic tags.
how do I remove them?
Comment From: dongsuo
Have you tried c.String
?
Comment From: chihiro-yabuta
thank you for your reply, @dongsuo but it is simple case, actually I want to get SVG tag. if I use string or writer, I got wrapped pre tag
if I attach html, I could get but html is not pure svg.
so I can't get api through url directly.
actually, I want to get api
<img src={url} />
like this.
Comment From: dongsuo
I think the pre
tag is added by Chrome. Try check the response in cURL
or postman, or network tab of Chrome Devtools?
Also I don't know what your purpose is, but I advice you use JSON struct to wrap your html string like this:
{
"html_snippet": "<img src={url} />"
}
**Comment From: chihiro-yabuta**
<img width="1260" alt="スクリーンショット 2022-11-22 17 34 20" src="https://user-images.githubusercontent.com/114799344/203264949-55664bc7-e499-4cb0-ba02-477efe653a43.png">
but safari renders as well.
I want to get **SVG**, not string.
and img is example.
I mean I want to be enable to distribute SVG image from url.
so now, I need to attach html tag and I wrote like this
github's readme doen't support iframe so I want to use img.
**Comment From: chihiro-yabuta**
@dongsuo
<img width="1400" alt="スクリーンショット 2022-11-22 18 02 10" src="https://user-images.githubusercontent.com/114799344/203271423-fe32fd90-f974-42fb-b84d-f9d9acc1d3f9.png">
I want to render like this
**Comment From: chihiro-yabuta**
<img width="1400" alt="スクリーンショット 2022-11-23 10 51 00" src="https://user-images.githubusercontent.com/114799344/203455083-58598271-2bfd-4ec1-bc3e-d780afb2cd22.png">
c.Writer.Header().Set("Content-Type", "image/svg+xml") ```
is answer for me.