summaryrefslogtreecommitdiffstats
path: root/golang
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-05-10 20:09:05 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-05-10 20:09:05 -0700
commite63d2b6c2bc7c7ecf5e57e4e25267113f8a1ed51 (patch)
tree4e08097208ddb26b50d9bed9cdf6fffef97fd8a2 /golang
parent63dc69bbcdbee264383b919f9a8a3b1a83358be7 (diff)
downloadfatcat-e63d2b6c2bc7c7ecf5e57e4e25267113f8a1ed51.tar.gz
fatcat-e63d2b6c2bc7c7ecf5e57e4e25267113f8a1ed51.zip
cleanups
Diffstat (limited to 'golang')
-rw-r--r--golang/TODO4
-rw-r--r--golang/api/handlers/editing.go18
-rw-r--r--golang/api/handlers/entities.go9
-rw-r--r--golang/cmd/fatcatd/serve.go22
4 files changed, 11 insertions, 42 deletions
diff --git a/golang/TODO b/golang/TODO
index a749cb79..89a1105c 100644
--- a/golang/TODO
+++ b/golang/TODO
@@ -8,8 +8,10 @@ x logging
x config
x sentry
x cobra command line parsing?
+x database creation and access
- test framework
-- database creation and access
+- panic recovery middleware
+- 404, not panic, when empty result
later:
- metrics
diff --git a/golang/api/handlers/editing.go b/golang/api/handlers/editing.go
index b0c006cb..5c267e9e 100644
--- a/golang/api/handlers/editing.go
+++ b/golang/api/handlers/editing.go
@@ -40,6 +40,7 @@ func GetOrCreateEditgroup() Editgroup {
return eg
}
+////
func NewGetEditorUsernameHandler(db *pg.DB) operations.GetEditorUsernameHandler {
return &getEditorUsername{db: db}
}
@@ -50,7 +51,7 @@ func (d *getEditorUsername) Handle(params operations.GetEditorUsernameParams) mi
return middleware.NotImplemented("operation .PostCreatorID has not yet been implemented")
}
-
+////
func NewGetEditorUsernameChangelogHandler(db *pg.DB) operations.GetEditorUsernameChangelogHandler {
return &getEditorUsernameChangelog{db: db}
}
@@ -61,6 +62,7 @@ func (d *getEditorUsernameChangelog) Handle(params operations.GetEditorUsernameC
return middleware.NotImplemented("operation .PostCreatorID has not yet been implemented")
}
+////
func NewGetEditgroupIDHandler(db *pg.DB) operations.GetEditgroupIDHandler {
return &getEditgroupID{db: db}
}
@@ -71,18 +73,7 @@ func (d *getEditgroupID) Handle(params operations.GetEditgroupIDParams) middlewa
return middleware.NotImplemented("operation .PostCreatorID has not yet been implemented")
}
-/*
-func NewGetEditgroupIDHandler(db *pg.DB) operations.GetEditgroupIDHandler {
- return &getEditgroupID{db: db}
-}
-type getCreatorID struct {
- db *pg.DB
-}
-func (d *getCreatorID) Handle(params operations.GetEditgroupIDParams) middleware.Responder {
- return middleware.NotImplemented("operation .PostCreatorID has not yet been implemented")
-}
-*/
-
+////
func NewPostEditgroupHandler(db *pg.DB) operations.PostEditgroupHandler {
return &postEditgroup{db: db}
}
@@ -93,6 +84,7 @@ func (d *postEditgroup) Handle(params operations.PostEditgroupParams) middleware
return middleware.NotImplemented("operation .PostEditgroupID has not yet been implemented")
}
+////
func NewPostEditgroupIDAcceptHandler(db *pg.DB) operations.PostEditgroupIDAcceptHandler {
return &postEditgroupIDAccept{db: db}
}
diff --git a/golang/api/handlers/entities.go b/golang/api/handlers/entities.go
index a2fb7db8..9e184d92 100644
--- a/golang/api/handlers/entities.go
+++ b/golang/api/handlers/entities.go
@@ -44,14 +44,13 @@ func (ci *CreatorIdent) State() string {
}
}
+////
func NewGetCreatorIDHandler(db *pg.DB) operations.GetCreatorIDHandler {
return &getCreatorID{db: db}
}
-
type getCreatorID struct {
db *pg.DB
}
-
func (d *getCreatorID) Handle(params operations.GetCreatorIDParams) middleware.Responder {
// "get or 404" using params.ID. join creator_ident and creator_rev.
// populate result data
@@ -75,28 +74,26 @@ func (d *getCreatorID) Handle(params operations.GetCreatorIDParams) middleware.R
return operations.NewGetCreatorIDOK().WithPayload(api_entity)
}
+////
func NewGetCreatorLookupHandler(db *pg.DB) operations.GetCreatorLookupHandler {
return &getCreatorLookup{db: db}
}
-
type getCreatorLookup struct {
db *pg.DB
}
-
func (d *getCreatorLookup) Handle(params operations.GetCreatorLookupParams) middleware.Responder {
// get-or-create editgroup based on current editor (session)
// insert new rev, ident, and edit
return middleware.NotImplemented("operation .GetCreatorLookup has not yet been implemented")
}
+////
func NewPostCreatorHandler(db *pg.DB) operations.PostCreatorHandler {
return &postCreator{db: db}
}
-
type postCreator struct {
db *pg.DB
}
-
func (d *postCreator) Handle(params operations.PostCreatorParams) middleware.Responder {
// get-or-create editgroup based on current editor (session)
// insert new rev, ident, and edit
diff --git a/golang/cmd/fatcatd/serve.go b/golang/cmd/fatcatd/serve.go
index 6f44e009..73eb1f86 100644
--- a/golang/cmd/fatcatd/serve.go
+++ b/golang/cmd/fatcatd/serve.go
@@ -58,34 +58,12 @@ func main_serve() {
api.GetCreatorIDHandler = handlers.NewGetCreatorIDHandler(db);
api.PostCreatorHandler = handlers.NewPostCreatorHandler(db);
api.GetCreatorLookupHandler = handlers.NewGetCreatorLookupHandler(db);
-/*
- api.GetCreatorLookupHandler = operations.GetCreatorLookupHandlerFunc(func(params operations.GetCreatorLookupParams) middleware.Responder {
- return middleware.NotImplemented("operation .GetCreatorLookup has not yet been implemented")
- })
-*/
api.GetEditgroupIDHandler = handlers.NewGetEditgroupIDHandler(db);
api.GetEditorUsernameHandler = handlers.NewGetEditorUsernameHandler(db);
api.GetEditorUsernameChangelogHandler = handlers.NewGetEditorUsernameChangelogHandler(db);
api.PostEditgroupHandler = handlers.NewPostEditgroupHandler(db);
api.PostEditgroupIDAcceptHandler = handlers.NewPostEditgroupIDAcceptHandler(db);
-/*
- api.GetEditgroupIDHandler = operations.GetEditgroupIDHandlerFunc(func(params operations.GetEditgroupIDParams) middleware.Responder {
- return middleware.NotImplemented("operation .GetEditgroupID has not yet been implemented")
- })
- api.GetEditorUsernameHandler = operations.GetEditorUsernameHandlerFunc(func(params operations.GetEditorUsernameParams) middleware.Responder {
- return middleware.NotImplemented("operation .GetEditorUsername has not yet been implemented")
- })
- api.GetEditorUsernameChangelogHandler = operations.GetEditorUsernameChangelogHandlerFunc(func(params operations.GetEditorUsernameChangelogParams) middleware.Responder {
- return middleware.NotImplemented("operation .GetEditorUsernameChangelog has not yet been implemented")
- })
- api.PostEditgroupHandler = operations.PostEditgroupHandlerFunc(func(params operations.PostEditgroupParams) middleware.Responder {
- return middleware.NotImplemented("operation .PostEditgroup has not yet been implemented")
- })
- api.PostEditgroupIDAcceptHandler = operations.PostEditgroupIDAcceptHandlerFunc(func(params operations.PostEditgroupIDAcceptParams) middleware.Responder {
- return middleware.NotImplemented("operation .PostEditgroupIDAccept has not yet been implemented")
- })
-*/
middle := interpose.New()