webapi

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commands

type Commands struct {
	//CmdArray []string `json:"commands"`
	Command  string   `json:"command"`
	Commands []string `json:"commands"`
}

type ConnectionCommand

type ConnectionCommand struct {
	Command  string `json:"command"`
	Port     string `json:"port,omitempty"`
	Baudrate int    `json:"baudrate,omitempty"`
}

type ConnectionReply

type ConnectionReply struct {
	Current struct {
		State          string `json:"state"`
		Port           string `json:"port"`
		Baudrate       int    `json:"baudrate"`
		PrinterProfile string `json:"printerProfile"`
	} `json:"current"`
	Options struct {
		Ports           []string `json:"ports"`
		Baudrates       []int    `json:"baudrates"`
		PrinterProfiles []struct {
			Name string `json:"name"`
			ID   string `json:"id"`
		} `json:"printerProfiles"`
		PortPreference           string `json:"portPreference"`
		BaudratePreference       int    `json:"baudratePreference"`
		PrinterProfilePreference string `json:"printerProfilePreference"`
		Autoconnect              bool   `json:"autoconnect"`
	} `json:"options"`
}

type FileStorage

type FileStorage interface {
	UploadFile(path, filename string, r io.ReadCloser) error
	ReadFile(path, filename string) (store.Stream, error)
}

type GcodeCommandRequest

type GcodeCommandRequest struct {
	Command string `json:"command"`
}

type WebApi

type WebApi struct {
	Version string
	// contains filtered or unexported fields
}

WebApi is the macro structure of Print2Go, implements and manages the server and web API, handling storage, print tasks, serial port and camera.

func New

func New(listenAddr string, store FileStorage, motdFile string, openSerial func(serial.SerialConfig) (hwserial.Port, error), shutdown func()) *WebApi

New creates a new WebApi instance. Starts a new task and returns the instance.

func (*WebApi) Run

func (wapi *WebApi) Run(srv *http.Server) error

Run starts the web server and binds the routes. returns the http server handle

func (*WebApi) SetVersion

func (wapi *WebApi) SetVersion(v string)

SetVersion sets the current version of Print2Go

Jump to

Keyboard shortcuts

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