Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/go-spring/starter-gin

「仅发布」gin 启动器 ( starter for gin )
https://github.com/go-spring/starter-gin

gin go-spring web

Last synced: 1 day ago
JSON representation

「仅发布」gin 启动器 ( starter for gin )

Awesome Lists containing this project

README

        

# starter-gin

[English](README_EN.md)

[仅发布] 该项目仅为最终发布,不要向该项目直接提交代码,开发请关注 [go-spring](https://github.com/go-spring/go-spring) 项目。

## Install

### Prerequisites

- Go >= 1.12

### Using go get

```
go get github.com/go-spring/[email protected]
```

## Quick Start

```
import _ "github.com/go-spring/starter-gin"
```

`main.go`

```
package main

import (
"fmt"

"github.com/go-spring/spring-core/gs"
"github.com/go-spring/spring-core/web"
_ "github.com/go-spring/starter-gin"
)

func init() {
gs.Object(new(Controller)).Init(func(c *Controller) {
gs.GetMapping("/", c.Hello)
})
}

type Controller struct {
GOPATH string `value:"${GOPATH}"`
}

func (c *Controller) Hello(ctx web.Context) {
ctx.String("%s - hello world!", c.GOPATH)
}

func main() {
fmt.Println(gs.Run())
}
```

`config/application.properties`

```
web.server.port=8000
```

```
➜ curl http://localhost:8000/
/Users/didi/work - hello world!
```

## Customization