shithub: mc

ref: f6e16f0c9f8d68a66c279059e4185d79a5b665a0
dir: /lib/http/types.myr/

View raw version
use std
use bio

pkg http =
	type status = int

	const Ok = 200

	type session = struct
		f	: bio.file#
		host	: byte[:]
		ua	: byte[:]
		err	: bool
	;;

	type server = struct
		lfd	: std.fd
	;;

	type router = struct
		paths	: route[:]
	;;

	type ctx = struct
		fd	: byte[:]
	;;

	type route = struct
		path	: byte[:]
		render	: (ctx : ctx# -> status)
	;;


	type url = struct
		schema	: schema
		port	: int
		host	: byte[:]
		path	: byte[:]
		params	: (byte[:], byte[:])[:]
	;;

	type err = union
		`Ewat
		`Eunsupp
		`Econn
		`Ehttp int
		`Ehdr
		`Eproto
		`Eshort
		`Esyntax
		`Eenc
	;;

	type schema = union
		`Http
		`Https
	;;

	type method = union
		`Get
		`Head
		`Put
		`Post
		`Delete
		`Trace
		`Options
	;;

	type encoding = union
		`Length
		`Chunked
		`Compress
		`Deflate
		`Gzip
	;;

	type req = struct
		url	: url#
		hdrs	: (byte[:], byte[:])[:]
	;;

	type resp = struct
		status	: int
		hdrs	: (byte[:], byte[:])[:]
		len	: std.size
		err	: std.option(err)
		reason	: byte[:]
		body	: byte[:]
		enc	: encoding
	;;

;;