boilerplate is added

This commit is contained in:
병준 박 2019-11-08 00:07:41 +09:00
parent 3e0e276f55
commit 73ea7e41cc
4 changed files with 58 additions and 3 deletions

26
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch - Server main",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/server/main.go",
"env": {},
"args": []
},
{
"name": "Launch - file",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"env": {},
"args": []
}
]
}

View File

@ -1,5 +1,19 @@
package main
func main() {
import (
"log"
"github.com/buaazp/fasthttprouter"
"github.com/valyala/fasthttp"
userHandlers "git.loafle.net/totopia/server/pkg/modules/user/handlers"
)
func main() {
router := fasthttprouter.New()
router.GET("/user/users", userHandlers.GetUsers)
router.POST("/user/users", userHandlers.PostUsers)
log.Fatal(fasthttp.ListenAndServe(":8080", router.Handler))
}

4
go.mod
View File

@ -3,6 +3,6 @@ module git.loafle.net/totopia/server
go 1.13
require (
github.com/buaazp/fasthttprouter v0.1.1 // indirect
github.com/valyala/fasthttp v1.6.0 // indirect
github.com/buaazp/fasthttprouter v0.1.1
github.com/valyala/fasthttp v1.6.0
)

View File

@ -0,0 +1,15 @@
package users
import (
"fmt"
"github.com/valyala/fasthttp"
)
func GetUsers(ctx *fasthttp.RequestCtx) {
fmt.Fprintf(ctx, "hello, %s!\n", ctx.UserValue("name"))
}
func PostUsers(ctx *fasthttp.RequestCtx) {
fmt.Fprintf(ctx, "hello, %s!\n", ctx.UserValue("name"))
}