Labstack/echo: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 43: Line 43:


=Registering Handlers Generated by oapi-codegen from an OpenAPI Specification=
=Registering Handlers Generated by oapi-codegen from an OpenAPI Specification=
==Implement <tt>oapi-codegen</tt>-generated <tt>ServerInterface</tt>==

Revision as of 20:52, 26 January 2024

External

Internal

Overview

Install Dependencies

From the root directory of your module, execute:

go get github.com/labstack/echo/v4@v4.11.4

Server

package main

import (
	"net/http"

	"github.com/labstack/echo/v4"
	"github.com/labstack/echo/v4/middleware"
)

func hello(c echo.Context) error {
	return c.String(http.StatusOK, "hello!")
}

func main() {
	s := echo.New()
	// Middleware
	s.Use(middleware.Logger())
	s.Use(middleware.Recover())
	// Routes
	s.GET("/", hello)
	// Start server
	s.Logger.Fatal(s.Start(":30000"))
}

Registering Handlers Generated by oapi-codegen from an OpenAPI Specification

Implement oapi-codegen-generated ServerInterface