Skip to content
getevoPublic

About

Evo is a powerful package for quickly writing modular web applications/services in Golang aimed both backend and frontend.

Topics

Resources

Code of conduct

Contributing

Stars

34 stars

Watchers

1 watching

Forks

Latest commit

 

History

615 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EVO Framework

EVO is a Go framework for building backend services. It gives you a web server, settings, a database layer with migrations, logging, caching, messaging and many small helpers, all under one import path.

You split your code into small apps. Each app registers its own routes, models and settings. EVO wires them together and starts the server.

package main

import "github.com/getevo/evo/v2"

func main() {
    if err := evo.Setup(); err != nil {
        panic(err)
    }
    evo.Get("/hello", func(r *evo.Request) any {
        return "hello world"
    })
    if err := evo.Run(); err != nil {
        panic(err)
    }
}

Run it and open http://localhost:8080/hello. You get {"success":true,"data":"hello world"}.

Table of Contents

Libraries

Every package in the lib folder:

Getting Started

  1. Add EVO to your module:

    go get github.com/getevo/evo/v2
  2. Write main.go like the example at the top. That's enough to start a server.

  3. Add a config.yml when you need one. It's optional. Without it, the server uses the default HTTP settings and listens on 0.0.0.0:8080.

    Here's a config with a database and the full HTTP section. It turns the database on, so you also need step 4:

    # config.yml
    Database:
      Enabled: true
      Type: mysql
      Server: 127.0.0.1:3306
      Username: root
      Password: password
      Database: mydb
      Debug: 3
      MaxOpenConns: 100
      MaxIdleConns: 10
      ConnMaxLifTime: 1h
      SlowQueryThreshold: 500ms
    HTTP:
      Host: 0.0.0.0
      Port: "8080"
      Network: tcp4
      Prefork: false
      ServerHeader: EVO NG
      StrictRouting: false
      CaseSensitive: false
      Immutable: false
      UnescapePath: false
      ETag: false
      BodyLimit: 128kb
      Concurrency: 1024
      ReadTimeout: 1s
      WriteTimeout: 5s
      IdleTimeout: 0
      ReadBufferSize: 8kb
      WriteBufferSize: 4kb
      CompressedFileSuffix: .evo.gz
      ProxyHeader: ""
      GETOnly: false
      DisableKeepalive: false
      DisableDefaultDate: false
      DisableDefaultContentType: false
      DisableHeaderNormalizing: false
      ReduceMemoryUsage: false
      EnablePrintRoutes: false
      Recover: true

    If you write an HTTP section, write all of it. Keys you leave out stay empty, they don't take the defaults. Only Recover stays on when it's missing. See Configuration.

    ProxyHeader is empty on purpose. Request.IP() already checks the common proxy headers (CF-Connecting-IP, X-Real-IP, X-Forwarded-For and others). Set it only if your proxy uses a different header.

    Recover: true means a panic in a handler returns 500 and the server keeps running.

  4. To use a database, pass its driver to evo.Setup:

    MySQL:

    package main
    
    import (
        "github.com/getevo/evo/v2"
        "github.com/getevo/evo/v2/lib/mysql"
    )
    
    func main() {
        if err := evo.Setup(mysql.Driver{}); err != nil {
            panic(err)
        }
        if err := evo.Run(); err != nil {
            panic(err)
        }
    }

    PostgreSQL: import github.com/getevo/evo/v2/lib/pgsql and call evo.Setup(pgsql.Driver{}).

    SQLite: import github.com/getevo/evo/v2/lib/sqlite and call evo.Setup(sqlite.Driver{}).

    Database.Type in your config must match the driver you pass.

About

Evo is a powerful package for quickly writing modular web applications/services in Golang aimed both backend and frontend.

Topics

Resources

Code of conduct

Contributing

Stars

34 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages