firmeve

package module
v0.0.0-...-3db6a0f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2020 License: MIT Imports: 7 Imported by: 0

README

This is a web framework that firmly believes in dreams.

Firmeve = Firm + Believe

Be firm in your will and believe in your ideals.(坚定自己的意志,相信自己的理想。)

Those who have achieved nothing can always tell you that you can't make a big deal. If you have an ideal, you have to defend it.(那些一事无成的人总是告诉你,你也成不了大器,如果你有理想的话,就要去捍卫它。)

Build Status codecov GitHub license Go Report Card

Quick start

go get -u github.com/firmeve/firmeve@develop

base

Docs

https://docs.firmeve.com/v/develop/

Example

package main

import (
    "fmt"
    "github.com/firmeve/firmeve"
    "github.com/firmeve/firmeve/http"
    "github.com/firmeve/firmeve/kernel/contract"
    "github.com/firmeve/firmeve/render"
)

func main() {
    firmeve.RunWithSupportFunc(
        application,
        firmeve.WithConfigPath("./config.yaml"),
        firmeve.WithProviders([]contract.Provider{
            new(http.Provider),
        }),
        firmeve.WithCommands([]contract.Command{
            new(http.HttpCommand),
        }),
    )
}

func application(application contract.Application) {
    router := application.Resolve(`http.router`).(contract.HttpRouter)
    router.GET("/", func(c contract.Context) {
        fmt.Printf("%t", c.Firmeve() == firmeve.Application)
        c.RenderWith(200, render.JSON, map[string]string{
            "ctx_application":    fmt.Sprintf("%p", c.Firmeve()),
            "global_application": fmt.Sprintf("%p", firmeve.Application),
        })

        c.Next()
    })

    v1 := router.Group("/api/v1")
    {
        v1.GET(`/ping`, func(c contract.Context) {
            c.RenderWith(200, render.JSON, map[string]string{
                "message": "pong",
            })
            c.Next()
        })
    }
}

Bootstrap command

go run main.go http:serve

Feature list

Directories

Path Synopsis
converter
examples
mock
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL