vendor dependencies with dep
This commit is contained in:
parent
93d8310491
commit
1384296a47
2712 changed files with 965742 additions and 0 deletions
22
vendor/github.com/go-chi/chi/_examples/versions/presenter/v1/article.go
generated
vendored
Normal file
22
vendor/github.com/go-chi/chi/_examples/versions/presenter/v1/article.go
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-chi/chi/_examples/versions/data"
|
||||
)
|
||||
|
||||
// Article presented in API version 1.
|
||||
type Article struct {
|
||||
*data.Article
|
||||
|
||||
Data map[string]bool `json:"data" xml:"data"`
|
||||
}
|
||||
|
||||
func (a *Article) Render(w http.ResponseWriter, r *http.Request) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewArticleResponse(article *data.Article) *Article {
|
||||
return &Article{Article: article}
|
||||
}
|
||||
30
vendor/github.com/go-chi/chi/_examples/versions/presenter/v2/article.go
generated
vendored
Normal file
30
vendor/github.com/go-chi/chi/_examples/versions/presenter/v2/article.go
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package v2
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-chi/chi/_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}
|
||||
}
|
||||
39
vendor/github.com/go-chi/chi/_examples/versions/presenter/v3/article.go
generated
vendored
Normal file
39
vendor/github.com/go-chi/chi/_examples/versions/presenter/v3/article.go
generated
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package v3
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-chi/chi/_examples/versions/data"
|
||||
)
|
||||
|
||||
// Article presented in API version 2.
|
||||
type Article struct {
|
||||
*data.Article `json:",inline" xml:",inline"`
|
||||
|
||||
// Additional fields.
|
||||
URL string `json:"url" xml:"url"`
|
||||
ViewsCount int64 `json:"views_count" xml:"views_count"`
|
||||
APIVersion string `json:"api_version" xml:"api_version"`
|
||||
|
||||
// Omitted fields.
|
||||
// Show custom_data explicitly for auth'd users only.
|
||||
CustomDataForAuthUsers interface{} `json:"custom_data,omitempty" xml:"custom_data,omitempty"`
|
||||
}
|
||||
|
||||
func (a *Article) Render(w http.ResponseWriter, r *http.Request) error {
|
||||
a.ViewsCount = rand.Int63n(100000)
|
||||
a.URL = fmt.Sprintf("http://localhost:3333/v3/?id=%v", a.ID)
|
||||
|
||||
// Only show to auth'd user.
|
||||
if _, ok := r.Context().Value("auth").(bool); ok {
|
||||
a.CustomDataForAuthUsers = a.Article.CustomDataForAuthUsers
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewArticleResponse(article *data.Article) *Article {
|
||||
return &Article{Article: article}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue