Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/instantan/web
Build robust web applications with pure Go. No external dependencies, just the power of the standard library.
https://github.com/instantan/web
openapi openapi3 redoc scalar swagger typescript-generator
Last synced: 20 days ago
JSON representation
Build robust web applications with pure Go. No external dependencies, just the power of the standard library.
- Host: GitHub
- URL: https://github.com/instantan/web
- Owner: Instantan
- License: mit
- Created: 2024-10-01T12:38:28.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-10-22T16:45:13.000Z (25 days ago)
- Last Synced: 2024-10-22T19:05:05.571Z (25 days ago)
- Topics: openapi, openapi3, redoc, scalar, swagger, typescript-generator
- Language: Go
- Homepage: https://web.instantan.io
- Size: 373 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
> Warning: This package is currently (not even) in alpha, not really tested yet and should not be used yet
## Todos
- Find a good api for defining sockets -> maybe dont implement sockets
- Content type handling in generated api## Key Features
- **Zero Dependencies**: Built entirely on Go's standard library. No external packages required.
- **OpenAPI Integration**: Automatically generate OpenAPI specifications for your APIs, enhancing documentation and interoperability.
- **TypeScript API generator**: Automatically generate TypeScript definitions for your Go APIs, ensuring type safety across your full-stack application.## Quick Start
Install with:
```bash
go get github.com/Instantan/web
```Example usage:
```go
package mainimport (
"log"
"net/http"
"github.com/Instantan/web"
)func main() {
w := web.NewWeb()w.Info(web.Info{
Title: "MyProject",
Version: "0.0.1",
})w.OpenApi(web.OpenApi{
DocPath: "/api/doc.json",
UiPath: "/api/doc",
UiVariant: "scalar",
})w.Api(web.Api{
Method: http.MethodGet,
Path: "/hello/{name}",
Parameter: web.Parameter{
Path: web.Path{
"name": web.PathParam{
Description: "The name to say hello to",
Value: "world",
},
},
},
Responses: web.Responses{
StatusOK: "Hello World",
},
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello " + r.PathValue("name")))
}),
})log.Println("Server listening on :8080")
log.Println("Visit http://localhost:8080/api/doc to view the documentation")
if err := http.ListenAndServe(":8080", w.Server()); err != nil {
panic(err)
}
}
```---
[![Go Report Card](https://goreportcard.com/badge/github.com/Instantan/web)](https://goreportcard.com/report/github.com/Instantan/web)