GithubHelp home page GithubHelp logo

goup's Introduction

goup

goup is a simple web framework, Born from gin and 7days-golang, it provides usage similar to (request, response) => { }

Run

New

engine := goup.New()
engine.GET("/", func (req Request, res Response) {
/* ... */
})
engine.Run(":9527")

Use

engine := goup.New()
engine.Use(func (req Request, res Response) {
/* ... */
})
engine.Use(Recovery(), Logger(), Cors())

Group

engine := goup.New()
api := engine.Group("/api")
api.GET("/xxx", func (req Request, res Response) {
/* ... */
})

File

engine := goup.New()
engine.File("/favicon.ico", "./public/favicon.ico")
engine.File("/public", "./public") //engine.Static("/public","./public")

Quick Use

Request get url
req.URL()

get host

req.Host()

get remote address

req.Addr()

get path, params

req.UseRouter()

get the key from params

req.Param(key)

get URLSearchParams

req.Query()

get key from URLSearchParams

req.GetQuery()

get the key from form

req.GetFormValue()

get the key file from form

req.GetFormFile()

get all headers

req.Header()

get the key from headers

req.GetHeader(key)

get all cookies

req.Cookies()

get the key from cookies

req.GetCookie(key)

get body as string

req.StringBody()

get body as bytes

req.BytesBody()

context

set value

req.Set(key, value)
req.SetValue(key, value)

get value

req.Get(key)
req.GetValue(key)
Response writeheader(status)
res.Status(200)
res.WriteHeader(200)

write

res.Write([]byte("hello"))
res.Bytes([]byte("hello"))
res.String("hello")

header

res.SetHeader("Content-Type", "text/html")

content type

res.ContentType("text/html")

set cookie

res.SetCookie(&cookie{})

html

res.HTML("index.html", map[string]any{
"title": "goup",
})

json

res.JSON(map[string]any{
"title": "goup",
})

status and error html page

res.Error(404, "Not Found.")

goup's People

Contributors

startracex avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.