Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
goa TIPS
goa in
2017/06/16
” ”
HAL
WEB 4
tikasan
tikasan0804
#goastudy
goa
goa


• GET /:id
• Header token 

• :id 

•
• GET /:id
• Header token 

• :id 

•
• GET /:id
• Header token 

• :id 

•
model
• GET /:id
• Header token 

• :id 

•
• GET /:id
• Header token 

• :id 

•
OSS
goa
VOYAGE GROUP 18 

goa@ 

https
ssh,https
push
master marge hook
deploy(rsync)
https
ssh,https
push
master marge hook
deploy(rsync)
v2
v1.2
v5.7
API
JSON
Client
JSON
v2
v1.2
v5.7
•
• 

• 

• 3
• 5
• 1 



View




• 

• 





goa
goa
1. DSL
2. DSL
3.
goa
1. DSL
2. DSL
3.
DSL
• app:
• main: main
• client: API Go
• js: JavaScript API
• swagger: API Swagger
• schema: API Hyper-schema JSON
• gen:
• ...
• app:
• main: main
• client: API Go
• js: JavaScript API
• swagger: API Swagger
• schema: API Hyper-schema JSON
• gen:
• ...
API Swagger 

swagger
Swagger
Swagger
API 

mock
goa+swagger
• goa swagger 

• swagger 

• 

REST 















Swagger
• DSL
• 







• goa
•
•
•
• goa
•
•
•
goa
goa Go WAF




goadesign/goa-celler goadesign/examples

• goa
•
•
•
Github issue


• goa
•
•
•
go goa 





go goa
• goa
•
•
•


goa
•
•
• data


goa
•
•
• data
※
•
•
• DSL
•
•
•
•
• DSL
•
•
.
!"" app/
!"" client/
!"" design/
!"" main.go
!"" public/
!"" store/
!"" tool/
!"" account.go <— .go
!"" bottle.go
!"" he...
Controller 

repo: github.com/goadesign/goa-cellar
controllers 

.go package controllers 

main.go mount 

controllers 

.
!"" app/
!"" client/
!"" main.go
!"" controllers <—
$   !"" account.go
$   !"" bottle.go
$   !"" health.go
$   !"" js.go...
•
•
• DSL
•
•
DSL
goa
#
gen: clean generate
clean:
@rm -rf app
@rm -rf client
@rm -rf tool
@rm -rf public/swagger
@rm -rf public/schema
@rm -rf ...
•
•
• DSL
•
•
DSL
package design
import (
. "github.com/goadesign/goa/design"
. "github.com/goadesign/goa/design/apidsl"
)
var _ = API("...
design
goa-celler
• api_definition.go

API
• media_types.go

MediaType
• resources.go

Resource
• user_types.go

Type
package design
import (
. "github.com/goadesign/goa/design"
. "github.com/goadesign/goa/design/apidsl"
)
// Account is the...
design
!"" api_definition.go
!"" medias <- MediaType
$   !"" accounts.go
$   #"" bottles.go
#"" resources <- Resource
   !...
Resource
package resources <— resources
import (
. “github.com/hoge/foo/design/constant" <— import
"github.com/hoge/foo/de...
•
•
• DSL
•
•
.
!"" app/
!"" client/
!"" controllers/
!"" design/
!"" main.go
!"" public/
!"" swagger/
#"" tool/
.
!"" app/
!"" client/
!"" controllers/
!"" design/
!"" main.go
!"" public/
!"" swagger/
#"" tool/
DSL 

DSL 

※


.
!"" app/
!"" client/
!"" controllers/
!"" design/
!"" main.go
!"" public/
!"" swagger/
#"" tool/
gitignore
design 



goagen 



goagen
•
•
• DSL
•
•


goa
goa
https://goa.design/ja/extend/generators/
https
ssh,https
push
master marge hook
deploy(rsync)
CI


• 

Swagger
• 

• issue
•
goa
go goa
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
Upcoming SlideShare
Loading in …5
×

goaを使った開発TIPS@六本木一丁目

1,114 views

Published on

goaの勉強会で発表した時に使った資料です
https://istyle.connpass.com/event/57455/

Published in: Technology
  • Be the first to comment

goaを使った開発TIPS@六本木一丁目

  1. 1. goa TIPS goa in 2017/06/16
  2. 2. ” ” HAL WEB 4 tikasan tikasan0804
  3. 3. #goastudy
  4. 4. goa
  5. 5. goa
  6. 6.
  7. 7. • GET /:id • Header token 
 • :id 
 •
  8. 8. • GET /:id • Header token 
 • :id 
 •
  9. 9. • GET /:id • Header token 
 • :id 
 •
  10. 10. model
  11. 11. • GET /:id • Header token 
 • :id 
 •
  12. 12. • GET /:id • Header token 
 • :id 
 •
  13. 13. OSS
  14. 14. goa
  15. 15. VOYAGE GROUP 18 

  16. 16. goa@ 

  17. 17. https ssh,https push master marge hook deploy(rsync)
  18. 18. https ssh,https push master marge hook deploy(rsync)
  19. 19. v2 v1.2 v5.7
  20. 20. API JSON Client JSON v2 v1.2 v5.7
  21. 21. • • 
 • 

  22. 22. • 3 • 5 • 1 
 

  23. 23. View 
 

  24. 24. • 
 • 
 

  25. 25.
  26. 26. goa
  27. 27. goa 1. DSL 2. DSL 3.
  28. 28. goa 1. DSL 2. DSL 3.
  29. 29. DSL
  30. 30. • app: • main: main • client: API Go • js: JavaScript API • swagger: API Swagger • schema: API Hyper-schema JSON • gen: • controller: • bootstrap: app main client swagger
  31. 31. • app: • main: main • client: API Go • js: JavaScript API • swagger: API Swagger • schema: API Hyper-schema JSON • gen: • controller: • bootstrap: app main client swagger
  32. 32. API Swagger 

  33. 33. swagger
  34. 34. Swagger
  35. 35. Swagger API 
 mock
  36. 36. goa+swagger • goa swagger 
 • swagger 
 • 

  37. 37. REST 

  38. 38. 
 
 
 
 
 

  39. 39. 
 Swagger
  40. 40. • DSL • 
 
 
 

  41. 41. • goa • • •
  42. 42. • goa • • •
  43. 43. goa goa Go WAF 
 
 goadesign/goa-celler goadesign/examples

  44. 44. • goa • • •
  45. 45. Github issue 

  46. 46. • goa • • •
  47. 47. go goa 

  48. 48.
  49. 49. 
 go goa
  50. 50. • goa • • •
  51. 51. 
 goa • • • data
  52. 52. 
 goa • • • data ※
  53. 53. • • • DSL • •
  54. 54. • • • DSL • •
  55. 55. . !"" app/ !"" client/ !"" design/ !"" main.go !"" public/ !"" store/ !"" tool/ !"" account.go <— .go !"" bottle.go !"" health.go !"" js.go !"" public.go #"" swagger.go
  56. 56. Controller 
 repo: github.com/goadesign/goa-cellar controllers 
 .go package controllers 
 main.go mount 
 controllers 

  57. 57. . !"" app/ !"" client/ !"" main.go !"" controllers <— $   !"" account.go $   !"" bottle.go $   !"" health.go $   !"" js.go $   !"" public.go $   #"" swagger.go !"" design/ !"" public/ #"" tool/
  58. 58. • • • DSL • •
  59. 59. DSL
  60. 60. goa
  61. 61. # gen: clean generate clean: @rm -rf app @rm -rf client @rm -rf tool @rm -rf public/swagger @rm -rf public/schema @rm -rf public/js @rm -f cellar generate: @goagen app -d github.com/goadesign/goa-cellar/design @goagen swagger -d github.com/goadesign/goa-cellar/design -o public @goagen schema -d github.com/goadesign/goa-cellar/design -o public @goagen client -d github.com/goadesign/goa-cellar/design @goagen js -d github.com/goadesign/goa-cellar/design -o public
  62. 62. • • • DSL • •
  63. 63. DSL package design import ( . "github.com/goadesign/goa/design" . "github.com/goadesign/goa/design/apidsl" ) var _ = API("appengine", func() { Title("The appengine example") Description("A simple appengine example") Contact(func() { Name("goa team") Email("admin@goa.design") URL("http://goa.design") }) License(func() { Name("MIT") URL("https://github.com/goadesign/goa/blob/master/LICENSE") }) Docs(func() { Description("goa guide") URL("http://goa.design/getting-started.html") }) Host("localhost:8080") Scheme("http") BasePath("/") Origin("*", func() { Methods("GET") MaxAge(600) Credentials() }) }) var ExampleMediaType = MediaType("application/vnd.example+json", func() { Description("example MediaType") Attributes(func() {
  64. 64. design
  65. 65. goa-celler • api_definition.go
 API • media_types.go
 MediaType • resources.go
 Resource • user_types.go
 Type
  66. 66. package design import ( . "github.com/goadesign/goa/design" . "github.com/goadesign/goa/design/apidsl" ) // Account is the account resource media type. var Account = MediaType("application/vnd.account+json", func() { Description("A tenant account") Attributes(func() { Attribute("id", Integer, "ID of account", func() { Example(1) }) Attribute("href", String, "API href of account", func() { Example("/accounts/1") }) Attribute("name", String, "Name of account", func() { Example("test") }) Attribute("created_at", DateTime, "Date of creation") Attribute("created_by", String, "Email of account owner", func() { Format("email") Example("me@goa.design") }) Required("id", "href", "name", "created_at", "created_by") }) View("default", func() { Attribute("id") Attribute("href") Attribute("name") Attribute("created_at") Attribute("created_by") })
  67. 67. design !"" api_definition.go !"" medias <- MediaType $   !"" accounts.go $   #"" bottles.go #"" resources <- Resource    !"" accounts.go    #"" bottles.go
  68. 68. Resource package resources <— resources import ( . “github.com/hoge/foo/design/constant" <— import "github.com/hoge/foo/design/media" <— import . "github.com/goadesign/goa/design" . "github.com/goadesign/goa/design/apidsl" ) var _ = Resource("accounts", func() { BasePath(“/accounts") // media.hoge DefaultMedia(media.accountsMedia) Action("create", func() { // }) })
  69. 69. • • • DSL • •
  70. 70. . !"" app/ !"" client/ !"" controllers/ !"" design/ !"" main.go !"" public/ !"" swagger/ #"" tool/
  71. 71. . !"" app/ !"" client/ !"" controllers/ !"" design/ !"" main.go !"" public/ !"" swagger/ #"" tool/
  72. 72. DSL 
 DSL 
 ※
  73. 73.
  74. 74. . !"" app/ !"" client/ !"" controllers/ !"" design/ !"" main.go !"" public/ !"" swagger/ #"" tool/ gitignore
  75. 75. design 
 
 goagen 
 
 goagen
  76. 76. • • • DSL • •
  77. 77.
  78. 78. goa
  79. 79. goa https://goa.design/ja/extend/generators/
  80. 80. https ssh,https push master marge hook deploy(rsync)
  81. 81. CI
  82. 82.
  83. 83. • 
 Swagger • 
 • issue •
  84. 84. goa go goa

×