...
1 package v2
2
3 import (
4 "fmt"
5 "net/http"
6
7 "github.com/go-chi/chi/_examples/versions/data"
8 )
9
10
11 type Article struct {
12
13
14 *data.Article
15
16
17 SelfURL string `json:"self_url" xml:"self_url"`
18
19
20 URL interface{} `json:"url,omitempty" xml:"url,omitempty"`
21 }
22
23 func (a *Article) Render(w http.ResponseWriter, r *http.Request) error {
24 a.SelfURL = fmt.Sprintf("http://localhost:3333/v2?id=%v", a.ID)
25 return nil
26 }
27
28 func NewArticleResponse(article *data.Article) *Article {
29 return &Article{Article: article}
30 }
31
View as plain text