Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/buzzer13/gosls
Golang serverless definitions and adapters
https://github.com/buzzer13/gosls
golang golang-library serverless
Last synced: about 11 hours ago
JSON representation
Golang serverless definitions and adapters
- Host: GitHub
- URL: https://github.com/buzzer13/gosls
- Owner: buzzer13
- License: mit
- Created: 2024-10-29T02:21:39.000Z (18 days ago)
- Default Branch: main
- Last Pushed: 2024-11-11T20:59:41.000Z (4 days ago)
- Last Synced: 2024-11-11T21:36:39.065Z (4 days ago)
- Topics: golang, golang-library, serverless
- Language: Go
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.txt
Awesome Lists containing this project
README
# GoSLS
[![latest release](https://img.shields.io/github/v/release/buzzer13/gosls)](https://github.com/buzzer13/gosls/releases)
This project provides structure definitions and helper methods for writing serverless functions in the Go programming language.
## Supported services
- [DigitalOcean Functions](https://docs.digitalocean.com/products/functions/)
- Supported runtime versions: `go:1.20`# Examples
```go
package mainimport (
"github.com/buzzer13/gosls/do"
"net/http"
)func Main(evm do.FuncEventMap) (do.FuncResponseMap, error) {
// Parse incoming event map
evt, err := evm.Event()if err != nil {
return (&do.FuncResponse{
Body: "event parse error - " + err.Error(),
StatusCode: http.StatusInternalServerError,
}).Map(), err
}// Generate http.Request from the Event object
req, err := evt.Request()if err != nil {
return (&do.FuncResponse{
Body: "request parse error - " + err.Error(),
StatusCode: http.StatusBadRequest,
}).Map(), err
}// Create response writer structure
res := do.FuncResponseWriter{}// Dispatch HTTP request to your app and write result to the response.
// With Echo framework this may be:
// echoInstance.ServeHTTP(&res, req)// Generate map from the response object and return it from the function
return res.GetFuncResponse().Map(), nil
}
```# Disclaimer
GoSLS is an unofficial library and is not affiliated with any of the companies whose services are supported by this library. All trademarks and registered trademarks are the property of their respective owners.