snapshot of https://github.com/go-chi/chi.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
Test / test (1.24.x, ubuntu-latest) (push) Successful in 2m56s
Test / test (1.25.x, ubuntu-latest) (push) Successful in 2m15s
Test / test (1.26.x, ubuntu-latest) (push) Successful in 2m23s
Test / test (1.27.x, ubuntu-latest) (push) Failing after 3m56s
Test / test (1.24.x, windows-latest) (push) Has been cancelled
Test / test (1.25.x, windows-latest) (push) Has been cancelled
Test / test (1.26.x, windows-latest) (push) Has been cancelled
Test / test (1.27.x, windows-latest) (push) Has been cancelled
Some checks failed
Test / test (1.24.x, ubuntu-latest) (push) Successful in 2m56s
Test / test (1.25.x, ubuntu-latest) (push) Successful in 2m15s
Test / test (1.26.x, ubuntu-latest) (push) Successful in 2m23s
Test / test (1.27.x, ubuntu-latest) (push) Failing after 3m56s
Test / test (1.24.x, windows-latest) (push) Has been cancelled
Test / test (1.25.x, windows-latest) (push) Has been cancelled
Test / test (1.26.x, windows-latest) (push) Has been cancelled
Test / test (1.27.x, windows-latest) (push) Has been cancelled
This commit is contained in:
30
_examples/versions/presenter/v2/article.go
Normal file
30
_examples/versions/presenter/v2/article.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package v2
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-chi/chi/v5/_examples/versions/data"
|
||||
)
|
||||
|
||||
// Article presented in API version 2.
|
||||
type Article struct {
|
||||
// *v3.Article `json:",inline" xml:",inline"`
|
||||
|
||||
*data.Article
|
||||
|
||||
// Additional fields.
|
||||
SelfURL string `json:"self_url" xml:"self_url"`
|
||||
|
||||
// Omitted fields.
|
||||
URL interface{} `json:"url,omitempty" xml:"url,omitempty"`
|
||||
}
|
||||
|
||||
func (a *Article) Render(w http.ResponseWriter, r *http.Request) error {
|
||||
a.SelfURL = fmt.Sprintf("http://localhost:3333/v2?id=%v", a.ID)
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewArticleResponse(article *data.Article) *Article {
|
||||
return &Article{Article: article}
|
||||
}
|
||||
Reference in New Issue
Block a user