boilerplate is added
This commit is contained in:
parent
3e0e276f55
commit
73ea7e41cc
26
.vscode/launch.json
vendored
Normal file
26
.vscode/launch.json
vendored
Normal 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": []
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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
4
go.mod
|
@ -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
|
||||
)
|
||||
|
|
15
pkg/modules/user/handlers/users.go
Normal file
15
pkg/modules/user/handlers/users.go
Normal 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"))
|
||||
}
|
Loading…
Reference in New Issue
Block a user