Worx is a framework for building APIs in Go with support for TMF (Telecom Management Forum) standards. Follow these steps to get started:
go get -u github.com/grahms/worx
Create a new Worx application:
package main
import (
"github.com/grahms/worx"
"github.com/grahms/worx/router"
)
func main() {
app := worx.NewApplication("/api", "Product Catalog API")
}
Create a new API endpoint using the NewRouter
function:
product := worx.NewRouter[Product, ProductResponse](app, "/products")
Define your request handling logic using the HandleCreate
, HandleRead
, HandleUpdate
, and HandleList
methods:
product.HandleCreate("", func(product Product, params *router.RequestParams) (*router.ProcessorError, *ProductResponse) {
return nil, &ProductResponse{
Product: product,
BaseType: nil,
Url: nil,
}
})
Start your Worx application and listen on a specified port:
err := app.Run(":8080")
if err != nil {
panic(err)
}
Now, your Worx application is ready to handle TMF API requests.
Make sure to include the route before defining the handlers to ensure that the routes are properly registered in your application. Happy coding