https://github.com/poteto-go/poteto
WebAPI Framework for golang
https://github.com/poteto-go/poteto
go go-library golang poteto webapi webframework
Last synced: about 1 month ago
JSON representation
WebAPI Framework for golang
- Host: GitHub
- URL: https://github.com/poteto-go/poteto
- Owner: poteto-go
- License: mit
- Created: 2024-08-29T05:11:06.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-02T09:09:51.000Z (10 months ago)
- Last Synced: 2025-01-02T10:24:49.887Z (10 months ago)
- Topics: go, go-library, golang, poteto, webapi, webframework
- Language: Go
- Homepage:
- Size: 327 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# Poteto
## Simple Web Framework of GoLang

```bash
go get -u github.com/poteto-go/poteto@latest
```If you try latest experiment version
https://github.com/poteto-go/poteto/blob/main/EXPERIMENT.md
```bash
go get -u github.com/poteto-go/poteto@exp
```## Deep Wiki
https://deepwiki.com/poteto-go/poteto
## Quick Start
```go
func main() {
p := poteto.New()
p.Register(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: []string{"*"},
AllowMethods: []string{http.MethodGet, http.MethodPut, http.MethodPost, http.MethodDelete},
}))p.GET("/", func(ctx poteto.Context) error {
return ctx.JSON(http.StatusOK, map[string]string{
"message": "Hello World",
})
})userApi := poteto.Api("/users", func(leaf poteto.Leaf) {
leaf.GET("/:id", func(ctx poteto.Context) error {
id, _ := p.PathParam("id")
return ctx.JSON(http.StatusOK, map[string]string{
"id": id,
})
})
})p.AddApi(userApi)
p.Run("3000")
}
```### UT
> [!NOTE]
> Poteto developers can easily test without setting up a server.```go
func main() {
p := poteto.New()p.GET("/users", func(ctx poteto.Context) error {
return ctx.JSON(http.StatusOK, map[string]string{
"id": "1",
"name": "tester",
})
})res := p.Play(http.MethodGet, "/users")
resBodyStr := res.Body.String
// => {"id":"1","name":"tester"}
}
```### middleware
use `poteto-extensions/middleware`
```bash
go get github.com/poteto-go/poteto-extensions
```## OIDC
poteto provides easily oidc middleware.
- verify signature
- jwt schema (if idp google).```go
func main() {
p := poteto.New()oidcConfig := middleware.OidcConfig {
Idp: "google",
ContextKey: "googleToken",
CacheMode: true,
JwksUrl: "https://www.googleapis.com/oauth2/v3/certs",
CachedVerifyTokenSignature: oidc.CachedVerifyTokenSignature,
}
p.Register(
middleware.OidcWithConfig(
oidcConfig,
)
)p.POST("/login", func(ctx poteto.Context) error {
var claims oidc.GoogleOidcClaims
token, _ := ctx.Get("googleToken")
json.Unmarshal(token.([]byte), &claims)
...
return ctx.JSON(200, map[string]string{"message": "success"})
})
}
```## Example App For Poteto
TODO
## Poteto-Cli
We support cli tool. But if you doesn't like it, you can create poteto-app w/o cli of course.
You can start hot-reload poteto app.
```sh
go install github.com/poteto-go/poteto-cli/cmd/poteto-cli@latest
```OR build from docker image
https://hub.docker.com/repository/docker/poteto17/poteto-go/general
```sh
docker pull poteto17/poteto-go
docker -it --rm poteto17/poteto-go:1.23 bash
```detail on:
https://github.com/poteto-go/poteto-cli