https://github.com/buzzer13/gosls
Golang serverless definitions and adapters
https://github.com/buzzer13/gosls
golang golang-library serverless
Last synced: 20 days 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 (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-11T20:59:41.000Z (over 1 year ago)
- Last Synced: 2025-01-16T07:16:21.786Z (over 1 year ago)
- Topics: golang, golang-library, serverless
- Language: Go
- Homepage:
- Size: 7.81 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
[](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 main
import (
"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.