ttp

package
v0.0.0-...-bbb754b Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: MIT Imports: 7 Imported by: 0

README

HulyTTP - Huly ty tut polzaesh

Http инструменты

  • Resp
    Возвращаем rest ответ в стандартизированном варианте Notify
Пример
import "github.com/xela07ax/toolsXela/hulyttp"
func sendMsg(w http.ResponseWriter, r *http.Request) {
	hulyttp.resp(w,r,"SendMsgNm", "Hello World", 0, true)
}

{"FuncName":"SendMsgNm","Text":"Hello World",Status":0,"Show":true,"UpdNum":0}

  • Upload file

curl http://localhost:8187/upload -F "fileupload=@README.md" -vvv curl http://localhost:8187/upload -F "fileupload=@logerWsWepPage-2.mp4" -vvv

Источник: https://stackoverflow.com/questions/40684307/how-can-i-receive-an-uploaded-file-using-a-golang-net-http-server

Upload file

еще примеры в папке _res*

	http.HandleFunc("/upload", func (w http.ResponseWriter, r *http.Request) {
		fmt.Println("File Upload Endpoint Hit")
		dat, err := ttp.UploadFileBytes(w,r)
		if err != nil {
			ertx:= fmt.Sprintf("файл не скачан |ertx:%s",err)
			http.Error(w, ertx, http.StatusBadGateway)
			fmt.Print(ertx)
			return
		}
Демонстрация

Demo ws front-back Xela golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllipLocal

func GetAllipLocal() (ips []string, err error)

func GetTryCleanIp

func GetTryCleanIp() (tryip string, err error)

func HttpBytes

func HttpBytes(w http.ResponseWriter, r *http.Request, res []byte) (err error)

func HttpReadBody

func HttpReadBody(w http.ResponseWriter, r *http.Request) ([]byte, error)

func Httpjson

func Httpjson(w http.ResponseWriter, r *http.Request, res interface{}) (err error)

func Resp

func Resp(w http.ResponseWriter, r *http.Request, funcName string, text string, status int, show bool)

func UploadFileBytes

func UploadFileBytes(w http.ResponseWriter, r *http.Request) (dat []byte, err error)

Types

type Notify

type Notify struct {
	FuncName string
	Text     string
	Status   int
	Show     bool
	UpdNum   int
}

Jump to

Keyboard shortcuts

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