/
githubmirror
/
GoFrame
Обзор
Документация
Войти
/
githubmirror
/
GoFrame
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
net/ghttp/ghttp_z_example_test.go
43 строки
982 B
John Guo
fix issue in configuration StdoutColorDisabled for package glog; rename TempDir to Temp for package gfile
14 фев 2022, 09:50
14 фев 2022, 09:50
5f2047d
Код
Авторство
О чём код?
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. // // This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT was not distributed with this file, // You can obtain one at https://github.com/gogf/gf. package ghttp_test import ( "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/os/gfile" ) func ExampleServer_Run() { s := g.Server() s.BindHandler("/", func(r *ghttp.Request) { r.Response.Write("hello world") }) s.SetPort(8999) s.Run() } // Custom saving file name. func ExampleUploadFile_Save() { s := g.Server() s.BindHandler("/upload", func(r *ghttp.Request) { file := r.GetUploadFile("TestFile") if file == nil { r.Response.Write("empty file") return } file.Filename = "MyCustomFileName.txt" fileName, err := file.Save(gfile.Temp()) if err != nil { r.Response.Write(err) return } r.Response.Write(fileName) }) s.SetPort(8999) s.Run() }