iris RESTful API

2022-03-26 10:42 更新

iris同樣支持RESTful API,具體使用方法如下

package main

import "github.com/kataras/iris/v12"

func main() {
    app := iris.Default()
	//需自行添加對(duì)應(yīng)函數(shù)
    app.Get("/someGet", getting)
	//func getting(ctx iris.Context){...}

    app.Post("/somePost", posting)
	//func posting(ctx iris.Context){...}

    app.Put("/somePut", putting)
	//func putting(ctx iris.Context){...}

    app.Delete("/someDelete", deleting)
	//func deleting(ctx iris.Context){...}

    app.Patch("/somePatch", patching)
	//func patching(ctx iris.Context){...}

    app.Header("/someHead", head)
	//func head(ctx iris.Context){...}

    app.Options("/someOptions", options)
	//func options(ctx iris.Context){...}

    app.Listen(":8080")
}


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)