update codegen
This commit is contained in:
@@ -21,6 +21,10 @@ import (
|
||||
"github.com/titpetric/factory/resputil"
|
||||
)
|
||||
|
||||
func (ch *ChannelHandlers) List(w http.ResponseWriter, r *http.Request) {
|
||||
params := channelListRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return ch.Channel.List(params) })
|
||||
}
|
||||
func (ch *ChannelHandlers) Create(w http.ResponseWriter, r *http.Request) {
|
||||
params := channelCreateRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return ch.Channel.Create(params) })
|
||||
@@ -29,15 +33,11 @@ func (ch *ChannelHandlers) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
params := channelEditRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return ch.Channel.Edit(params) })
|
||||
}
|
||||
func (ch *ChannelHandlers) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
params := channelDeleteRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return ch.Channel.Delete(params) })
|
||||
}
|
||||
func (ch *ChannelHandlers) Read(w http.ResponseWriter, r *http.Request) {
|
||||
params := channelReadRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return ch.Channel.Read(params) })
|
||||
}
|
||||
func (ch *ChannelHandlers) Search(w http.ResponseWriter, r *http.Request) {
|
||||
params := channelSearchRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return ch.Channel.Search(params) })
|
||||
func (ch *ChannelHandlers) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
params := channelDeleteRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return ch.Channel.Delete(params) })
|
||||
}
|
||||
|
||||
@@ -32,20 +32,20 @@ func (ChannelHandlers) new() *ChannelHandlers {
|
||||
|
||||
// Internal API interface
|
||||
type ChannelAPI interface {
|
||||
List(*channelListRequest) (interface{}, error)
|
||||
Create(*channelCreateRequest) (interface{}, error)
|
||||
Edit(*channelEditRequest) (interface{}, error)
|
||||
Delete(*channelDeleteRequest) (interface{}, error)
|
||||
Read(*channelReadRequest) (interface{}, error)
|
||||
Search(*channelSearchRequest) (interface{}, error)
|
||||
Delete(*channelDeleteRequest) (interface{}, error)
|
||||
}
|
||||
|
||||
// HTTP API interface
|
||||
type ChannelHandlersAPI interface {
|
||||
List(http.ResponseWriter, *http.Request)
|
||||
Create(http.ResponseWriter, *http.Request)
|
||||
Edit(http.ResponseWriter, *http.Request)
|
||||
Delete(http.ResponseWriter, *http.Request)
|
||||
Read(http.ResponseWriter, *http.Request)
|
||||
Search(http.ResponseWriter, *http.Request)
|
||||
Delete(http.ResponseWriter, *http.Request)
|
||||
}
|
||||
|
||||
// Compile time check to see if we implement the interfaces
|
||||
|
||||
+36
-36
@@ -22,6 +22,34 @@ import (
|
||||
|
||||
var _ = chi.URLParam
|
||||
|
||||
// Channel list request parameters
|
||||
type channelListRequest struct {
|
||||
query string
|
||||
}
|
||||
|
||||
func (channelListRequest) new() *channelListRequest {
|
||||
return &channelListRequest{}
|
||||
}
|
||||
|
||||
func (c *channelListRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
for name, param := range urlQuery {
|
||||
get[name] = string(param[0])
|
||||
}
|
||||
postVars := r.Form
|
||||
for name, param := range postVars {
|
||||
post[name] = string(param[0])
|
||||
}
|
||||
|
||||
c.query = get["query"]
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ RequestFiller = channelListRequest{}.new()
|
||||
|
||||
// Channel create request parameters
|
||||
type channelCreateRequest struct {
|
||||
name string
|
||||
@@ -93,34 +121,6 @@ func (c *channelEditRequest) Fill(r *http.Request) error {
|
||||
|
||||
var _ RequestFiller = channelEditRequest{}.new()
|
||||
|
||||
// Channel delete request parameters
|
||||
type channelDeleteRequest struct {
|
||||
id uint64
|
||||
}
|
||||
|
||||
func (channelDeleteRequest) new() *channelDeleteRequest {
|
||||
return &channelDeleteRequest{}
|
||||
}
|
||||
|
||||
func (c *channelDeleteRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
for name, param := range urlQuery {
|
||||
get[name] = string(param[0])
|
||||
}
|
||||
postVars := r.Form
|
||||
for name, param := range postVars {
|
||||
post[name] = string(param[0])
|
||||
}
|
||||
|
||||
c.id = parseUInt64(get["id"])
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ RequestFiller = channelDeleteRequest{}.new()
|
||||
|
||||
// Channel read request parameters
|
||||
type channelReadRequest struct {
|
||||
id uint64
|
||||
@@ -149,16 +149,16 @@ func (c *channelReadRequest) Fill(r *http.Request) error {
|
||||
|
||||
var _ RequestFiller = channelReadRequest{}.new()
|
||||
|
||||
// Channel search request parameters
|
||||
type channelSearchRequest struct {
|
||||
query string
|
||||
// Channel delete request parameters
|
||||
type channelDeleteRequest struct {
|
||||
id uint64
|
||||
}
|
||||
|
||||
func (channelSearchRequest) new() *channelSearchRequest {
|
||||
return &channelSearchRequest{}
|
||||
func (channelDeleteRequest) new() *channelDeleteRequest {
|
||||
return &channelDeleteRequest{}
|
||||
}
|
||||
|
||||
func (c *channelSearchRequest) Fill(r *http.Request) error {
|
||||
func (c *channelDeleteRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
@@ -171,8 +171,8 @@ func (c *channelSearchRequest) Fill(r *http.Request) error {
|
||||
post[name] = string(param[0])
|
||||
}
|
||||
|
||||
c.query = get["query"]
|
||||
c.id = parseUInt64(get["id"])
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ RequestFiller = channelSearchRequest{}.new()
|
||||
var _ RequestFiller = channelDeleteRequest{}.new()
|
||||
|
||||
@@ -21,6 +21,14 @@ import (
|
||||
"github.com/titpetric/factory/resputil"
|
||||
)
|
||||
|
||||
func (oh *OrganisationHandlers) List(w http.ResponseWriter, r *http.Request) {
|
||||
params := organisationListRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return oh.Organisation.List(params) })
|
||||
}
|
||||
func (oh *OrganisationHandlers) Create(w http.ResponseWriter, r *http.Request) {
|
||||
params := organisationCreateRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return oh.Organisation.Create(params) })
|
||||
}
|
||||
func (oh *OrganisationHandlers) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
params := organisationEditRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return oh.Organisation.Edit(params) })
|
||||
@@ -33,10 +41,6 @@ func (oh *OrganisationHandlers) Read(w http.ResponseWriter, r *http.Request) {
|
||||
params := organisationReadRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return oh.Organisation.Read(params) })
|
||||
}
|
||||
func (oh *OrganisationHandlers) Search(w http.ResponseWriter, r *http.Request) {
|
||||
params := organisationSearchRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return oh.Organisation.Search(params) })
|
||||
}
|
||||
func (oh *OrganisationHandlers) Archive(w http.ResponseWriter, r *http.Request) {
|
||||
params := organisationArchiveRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return oh.Organisation.Archive(params) })
|
||||
|
||||
@@ -32,19 +32,21 @@ func (OrganisationHandlers) new() *OrganisationHandlers {
|
||||
|
||||
// Internal API interface
|
||||
type OrganisationAPI interface {
|
||||
List(*organisationListRequest) (interface{}, error)
|
||||
Create(*organisationCreateRequest) (interface{}, error)
|
||||
Edit(*organisationEditRequest) (interface{}, error)
|
||||
Remove(*organisationRemoveRequest) (interface{}, error)
|
||||
Read(*organisationReadRequest) (interface{}, error)
|
||||
Search(*organisationSearchRequest) (interface{}, error)
|
||||
Archive(*organisationArchiveRequest) (interface{}, error)
|
||||
}
|
||||
|
||||
// HTTP API interface
|
||||
type OrganisationHandlersAPI interface {
|
||||
List(http.ResponseWriter, *http.Request)
|
||||
Create(http.ResponseWriter, *http.Request)
|
||||
Edit(http.ResponseWriter, *http.Request)
|
||||
Remove(http.ResponseWriter, *http.Request)
|
||||
Read(http.ResponseWriter, *http.Request)
|
||||
Search(http.ResponseWriter, *http.Request)
|
||||
Archive(http.ResponseWriter, *http.Request)
|
||||
}
|
||||
|
||||
|
||||
+59
-31
@@ -22,6 +22,62 @@ import (
|
||||
|
||||
var _ = chi.URLParam
|
||||
|
||||
// Organisation list request parameters
|
||||
type organisationListRequest struct {
|
||||
query string
|
||||
}
|
||||
|
||||
func (organisationListRequest) new() *organisationListRequest {
|
||||
return &organisationListRequest{}
|
||||
}
|
||||
|
||||
func (o *organisationListRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
for name, param := range urlQuery {
|
||||
get[name] = string(param[0])
|
||||
}
|
||||
postVars := r.Form
|
||||
for name, param := range postVars {
|
||||
post[name] = string(param[0])
|
||||
}
|
||||
|
||||
o.query = get["query"]
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ RequestFiller = organisationListRequest{}.new()
|
||||
|
||||
// Organisation create request parameters
|
||||
type organisationCreateRequest struct {
|
||||
name string
|
||||
}
|
||||
|
||||
func (organisationCreateRequest) new() *organisationCreateRequest {
|
||||
return &organisationCreateRequest{}
|
||||
}
|
||||
|
||||
func (o *organisationCreateRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
for name, param := range urlQuery {
|
||||
get[name] = string(param[0])
|
||||
}
|
||||
postVars := r.Form
|
||||
for name, param := range postVars {
|
||||
post[name] = string(param[0])
|
||||
}
|
||||
|
||||
o.name = post["name"]
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ RequestFiller = organisationCreateRequest{}.new()
|
||||
|
||||
// Organisation edit request parameters
|
||||
type organisationEditRequest struct {
|
||||
id uint64
|
||||
@@ -45,7 +101,7 @@ func (o *organisationEditRequest) Fill(r *http.Request) error {
|
||||
post[name] = string(param[0])
|
||||
}
|
||||
|
||||
o.id = parseUInt64(post["id"])
|
||||
o.id = chi.URLParam(r, "id")
|
||||
|
||||
o.name = post["name"]
|
||||
return nil
|
||||
@@ -75,7 +131,7 @@ func (o *organisationRemoveRequest) Fill(r *http.Request) error {
|
||||
post[name] = string(param[0])
|
||||
}
|
||||
|
||||
o.id = parseUInt64(get["id"])
|
||||
o.id = chi.URLParam(r, "id")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -109,34 +165,6 @@ func (o *organisationReadRequest) Fill(r *http.Request) error {
|
||||
|
||||
var _ RequestFiller = organisationReadRequest{}.new()
|
||||
|
||||
// Organisation search request parameters
|
||||
type organisationSearchRequest struct {
|
||||
query string
|
||||
}
|
||||
|
||||
func (organisationSearchRequest) new() *organisationSearchRequest {
|
||||
return &organisationSearchRequest{}
|
||||
}
|
||||
|
||||
func (o *organisationSearchRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
for name, param := range urlQuery {
|
||||
get[name] = string(param[0])
|
||||
}
|
||||
postVars := r.Form
|
||||
for name, param := range postVars {
|
||||
post[name] = string(param[0])
|
||||
}
|
||||
|
||||
o.query = get["query"]
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ RequestFiller = organisationSearchRequest{}.new()
|
||||
|
||||
// Organisation archive request parameters
|
||||
type organisationArchiveRequest struct {
|
||||
id uint64
|
||||
@@ -159,7 +187,7 @@ func (o *organisationArchiveRequest) Fill(r *http.Request) error {
|
||||
post[name] = string(param[0])
|
||||
}
|
||||
|
||||
o.id = parseUInt64(post["id"])
|
||||
o.id = chi.URLParam(r, "id")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
+17
-15
@@ -30,11 +30,11 @@ func MountRoutes(r chi.Router) {
|
||||
user := UserHandlers{}.new()
|
||||
websocket := WebsocketHandlers{}.new()
|
||||
r.Route("/channel", func(r chi.Router) {
|
||||
r.Post("/create", channel.Create)
|
||||
r.Get("/", channel.List)
|
||||
r.Put("/", channel.Create)
|
||||
r.Post("/edit", channel.Edit)
|
||||
r.Delete("/delete", channel.Delete)
|
||||
r.Get("/read", channel.Read)
|
||||
r.Get("/search", channel.Search)
|
||||
r.Delete("/delete", channel.Delete)
|
||||
})
|
||||
r.Route("/message", func(r chi.Router) {
|
||||
r.Post("/edit", message.Edit)
|
||||
@@ -46,20 +46,22 @@ func MountRoutes(r chi.Router) {
|
||||
r.Post("/flag", message.Flag)
|
||||
})
|
||||
r.Route("/organisation", func(r chi.Router) {
|
||||
r.Post("/edit", organisation.Edit)
|
||||
r.Delete("/remove", organisation.Remove)
|
||||
r.Get("/read", organisation.Read)
|
||||
r.Get("/search", organisation.Search)
|
||||
r.Post("/archive", organisation.Archive)
|
||||
r.Get("/", organisation.List)
|
||||
r.Put("/", organisation.Create)
|
||||
r.Post("/{id}", organisation.Edit)
|
||||
r.Delete("/{id}", organisation.Remove)
|
||||
r.Get("/{id}", organisation.Read)
|
||||
r.Post("/{id}/archive", organisation.Archive)
|
||||
})
|
||||
r.Route("/team", func(r chi.Router) {
|
||||
r.Post("/edit", team.Edit)
|
||||
r.Delete("/remove", team.Remove)
|
||||
r.Get("/read", team.Read)
|
||||
r.Get("/search", team.Search)
|
||||
r.Post("/archive", team.Archive)
|
||||
r.Post("/move", team.Move)
|
||||
r.Post("/merge", team.Merge)
|
||||
r.Get("/", team.List)
|
||||
r.Put("/", team.Create)
|
||||
r.Post("/{id}", team.Edit)
|
||||
r.Get("/{id}", team.Read)
|
||||
r.Delete("/{id}", team.Remove)
|
||||
r.Post("/{id}/archive", team.Archive)
|
||||
r.Post("/{id}/move", team.Move)
|
||||
r.Post("/{id}/merge", team.Merge)
|
||||
})
|
||||
r.Route("/user", func(r chi.Router) {
|
||||
r.Post("/login", user.Login)
|
||||
|
||||
+11
-7
@@ -21,21 +21,25 @@ import (
|
||||
"github.com/titpetric/factory/resputil"
|
||||
)
|
||||
|
||||
func (th *TeamHandlers) List(w http.ResponseWriter, r *http.Request) {
|
||||
params := teamListRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return th.Team.List(params) })
|
||||
}
|
||||
func (th *TeamHandlers) Create(w http.ResponseWriter, r *http.Request) {
|
||||
params := teamCreateRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return th.Team.Create(params) })
|
||||
}
|
||||
func (th *TeamHandlers) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
params := teamEditRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return th.Team.Edit(params) })
|
||||
}
|
||||
func (th *TeamHandlers) Remove(w http.ResponseWriter, r *http.Request) {
|
||||
params := teamRemoveRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return th.Team.Remove(params) })
|
||||
}
|
||||
func (th *TeamHandlers) Read(w http.ResponseWriter, r *http.Request) {
|
||||
params := teamReadRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return th.Team.Read(params) })
|
||||
}
|
||||
func (th *TeamHandlers) Search(w http.ResponseWriter, r *http.Request) {
|
||||
params := teamSearchRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return th.Team.Search(params) })
|
||||
func (th *TeamHandlers) Remove(w http.ResponseWriter, r *http.Request) {
|
||||
params := teamRemoveRequest{}.new()
|
||||
resputil.JSON(w, params.Fill(r), func() (interface{}, error) { return th.Team.Remove(params) })
|
||||
}
|
||||
func (th *TeamHandlers) Archive(w http.ResponseWriter, r *http.Request) {
|
||||
params := teamArchiveRequest{}.new()
|
||||
|
||||
@@ -32,10 +32,11 @@ func (TeamHandlers) new() *TeamHandlers {
|
||||
|
||||
// Internal API interface
|
||||
type TeamAPI interface {
|
||||
List(*teamListRequest) (interface{}, error)
|
||||
Create(*teamCreateRequest) (interface{}, error)
|
||||
Edit(*teamEditRequest) (interface{}, error)
|
||||
Remove(*teamRemoveRequest) (interface{}, error)
|
||||
Read(*teamReadRequest) (interface{}, error)
|
||||
Search(*teamSearchRequest) (interface{}, error)
|
||||
Remove(*teamRemoveRequest) (interface{}, error)
|
||||
Archive(*teamArchiveRequest) (interface{}, error)
|
||||
Move(*teamMoveRequest) (interface{}, error)
|
||||
Merge(*teamMergeRequest) (interface{}, error)
|
||||
@@ -43,10 +44,11 @@ type TeamAPI interface {
|
||||
|
||||
// HTTP API interface
|
||||
type TeamHandlersAPI interface {
|
||||
List(http.ResponseWriter, *http.Request)
|
||||
Create(http.ResponseWriter, *http.Request)
|
||||
Edit(http.ResponseWriter, *http.Request)
|
||||
Remove(http.ResponseWriter, *http.Request)
|
||||
Read(http.ResponseWriter, *http.Request)
|
||||
Search(http.ResponseWriter, *http.Request)
|
||||
Remove(http.ResponseWriter, *http.Request)
|
||||
Archive(http.ResponseWriter, *http.Request)
|
||||
Move(http.ResponseWriter, *http.Request)
|
||||
Merge(http.ResponseWriter, *http.Request)
|
||||
|
||||
+72
-43
@@ -22,6 +22,63 @@ import (
|
||||
|
||||
var _ = chi.URLParam
|
||||
|
||||
// Team list request parameters
|
||||
type teamListRequest struct {
|
||||
query string
|
||||
}
|
||||
|
||||
func (teamListRequest) new() *teamListRequest {
|
||||
return &teamListRequest{}
|
||||
}
|
||||
|
||||
func (t *teamListRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
for name, param := range urlQuery {
|
||||
get[name] = string(param[0])
|
||||
}
|
||||
postVars := r.Form
|
||||
for name, param := range postVars {
|
||||
post[name] = string(param[0])
|
||||
}
|
||||
|
||||
t.query = get["query"]
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ RequestFiller = teamListRequest{}.new()
|
||||
|
||||
// Team create request parameters
|
||||
type teamCreateRequest struct {
|
||||
name string
|
||||
members []uint64
|
||||
}
|
||||
|
||||
func (teamCreateRequest) new() *teamCreateRequest {
|
||||
return &teamCreateRequest{}
|
||||
}
|
||||
|
||||
func (t *teamCreateRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
for name, param := range urlQuery {
|
||||
get[name] = string(param[0])
|
||||
}
|
||||
postVars := r.Form
|
||||
for name, param := range postVars {
|
||||
post[name] = string(param[0])
|
||||
}
|
||||
|
||||
t.name = post["name"]
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ RequestFiller = teamCreateRequest{}.new()
|
||||
|
||||
// Team edit request parameters
|
||||
type teamEditRequest struct {
|
||||
id uint64
|
||||
@@ -46,7 +103,7 @@ func (t *teamEditRequest) Fill(r *http.Request) error {
|
||||
post[name] = string(param[0])
|
||||
}
|
||||
|
||||
t.id = parseUInt64(post["id"])
|
||||
t.id = chi.URLParam(r, "id")
|
||||
|
||||
t.name = post["name"]
|
||||
return nil
|
||||
@@ -54,34 +111,6 @@ func (t *teamEditRequest) Fill(r *http.Request) error {
|
||||
|
||||
var _ RequestFiller = teamEditRequest{}.new()
|
||||
|
||||
// Team remove request parameters
|
||||
type teamRemoveRequest struct {
|
||||
id uint64
|
||||
}
|
||||
|
||||
func (teamRemoveRequest) new() *teamRemoveRequest {
|
||||
return &teamRemoveRequest{}
|
||||
}
|
||||
|
||||
func (t *teamRemoveRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
for name, param := range urlQuery {
|
||||
get[name] = string(param[0])
|
||||
}
|
||||
postVars := r.Form
|
||||
for name, param := range postVars {
|
||||
post[name] = string(param[0])
|
||||
}
|
||||
|
||||
t.id = parseUInt64(get["id"])
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ RequestFiller = teamRemoveRequest{}.new()
|
||||
|
||||
// Team read request parameters
|
||||
type teamReadRequest struct {
|
||||
id uint64
|
||||
@@ -104,22 +133,22 @@ func (t *teamReadRequest) Fill(r *http.Request) error {
|
||||
post[name] = string(param[0])
|
||||
}
|
||||
|
||||
t.id = parseUInt64(get["id"])
|
||||
t.id = chi.URLParam(r, "id")
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ RequestFiller = teamReadRequest{}.new()
|
||||
|
||||
// Team search request parameters
|
||||
type teamSearchRequest struct {
|
||||
query string
|
||||
// Team remove request parameters
|
||||
type teamRemoveRequest struct {
|
||||
id uint64
|
||||
}
|
||||
|
||||
func (teamSearchRequest) new() *teamSearchRequest {
|
||||
return &teamSearchRequest{}
|
||||
func (teamRemoveRequest) new() *teamRemoveRequest {
|
||||
return &teamRemoveRequest{}
|
||||
}
|
||||
|
||||
func (t *teamSearchRequest) Fill(r *http.Request) error {
|
||||
func (t *teamRemoveRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
@@ -132,11 +161,11 @@ func (t *teamSearchRequest) Fill(r *http.Request) error {
|
||||
post[name] = string(param[0])
|
||||
}
|
||||
|
||||
t.query = get["query"]
|
||||
t.id = chi.URLParam(r, "id")
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ RequestFiller = teamSearchRequest{}.new()
|
||||
var _ RequestFiller = teamRemoveRequest{}.new()
|
||||
|
||||
// Team archive request parameters
|
||||
type teamArchiveRequest struct {
|
||||
@@ -160,7 +189,7 @@ func (t *teamArchiveRequest) Fill(r *http.Request) error {
|
||||
post[name] = string(param[0])
|
||||
}
|
||||
|
||||
t.id = parseUInt64(post["id"])
|
||||
t.id = chi.URLParam(r, "id")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -189,7 +218,7 @@ func (t *teamMoveRequest) Fill(r *http.Request) error {
|
||||
post[name] = string(param[0])
|
||||
}
|
||||
|
||||
t.id = parseUInt64(post["id"])
|
||||
t.id = chi.URLParam(r, "id")
|
||||
|
||||
t.organisation_id = parseUInt64(post["organisation_id"])
|
||||
return nil
|
||||
@@ -199,8 +228,8 @@ var _ RequestFiller = teamMoveRequest{}.new()
|
||||
|
||||
// Team merge request parameters
|
||||
type teamMergeRequest struct {
|
||||
id uint64
|
||||
destination uint64
|
||||
source uint64
|
||||
}
|
||||
|
||||
func (teamMergeRequest) new() *teamMergeRequest {
|
||||
@@ -220,9 +249,9 @@ func (t *teamMergeRequest) Fill(r *http.Request) error {
|
||||
post[name] = string(param[0])
|
||||
}
|
||||
|
||||
t.destination = parseUInt64(post["destination"])
|
||||
t.id = chi.URLParam(r, "id")
|
||||
|
||||
t.source = parseUInt64(post["source"])
|
||||
t.destination = parseUInt64(post["destination"])
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user