Categorygithub.com/Mth-Ryan/echo_router_builder
modulepackage
0.0.0-20230614192607-1775dd67d946
Repository: https://github.com/mth-ryan/echo_router_builder.git
Documentation: pkg.go.dev

# README

Echo router builder

A builder design pattern for the echo framework router. This lib made mvc projects easier to create and simpler to maintain. See the example bellow:

Example

controller file: controllers/access.go:


package controllers

import (
  "github.com/labstack/echo/v4"
  r "github.com/Mth-Ryan/echo_router_builder"
)

AccessController = r.NewController("/access").
  View("/login", "login.tmpl.html", nil).
  Post("/login", loginAction))
  
func loginAction(c echo.Context) error {
  ...
}

main file: main.go

  package main
  
  import (
    m "github.com/labstack/echo/v4/middleware"
    r "github.com/Mth-Ryan/echo_router_builder"
    "example.com/project/controllers"
  )
  
  builder := r.NewBuilder(m.Logger(), m.Recovery()).
    RegisterStatic("/public", "assets").
    RegisterViews("views", ".tmpl.html").
    Register(AccessController)
    
  e := builder.Build
  e.Logger.Fatal(e.Start(":8080"))

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author