本书未发布

10.1. 使用https

未匹配的标注
package main

/*
ListenTLS方法一般均默认开启了h2,如果需要仅开启https,需要手动listen监听然后使用app.Serve启动服务。
*/

import (
    "crypto/tls"
    "net/http"

    "github.com/eudore/eudore"
    "github.com/eudore/eudore/component/httptest"
)

func main() {
    app := eudore.NewApp()
    app.AnyFunc("/*", func(ctx eudore.Context) {
        ctx.Debug("istls:", ctx.Istls())
    })
    // 使用空证书会自动签发私人证书。
    app.ListenTLS(":8089", "", "")

    client := httptest.NewClient(app)
    client.Client.Transport = &http.Transport{
        TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
    }
    client.NewRequest("GET", "https://localhost:8089/").Do().CheckStatus(200).Out()

    // app.CancelFunc()
    app.Run()
}

反馈和交流请加群组:QQ群373278915

本文章首发在 LearnKu.com 网站上。

上一篇 下一篇
讨论数量: 0
发起讨论 只看当前版本


暂无话题~