Search results

There are no results.

std.net.http.Method

Value
type pub copy enum Method

An HTTP request method.

Only the standard request methods defined in RFC 9112 are supported. Custom request methods aren't supported as they're virtually unused, and frankly not that useful.

Constructors

Connect

Connect()

Delete

Delete()

Get

Get()

Head

Head()

Options

Options()

Post

Post()

Put

Put()

Trace

Trace()

Static methods

parse

Show source code
Hide source code
fn pub static parse[B: Bytes](input: ref B) -> Option[Method] {
  method.parse(input)
}
fn pub static parse[B: Bytes](input: ref B) -> Option[Method]

Creates a Method from a sequence of bytes.

If the request method isn't recognized, an Option.None is returned.

Examples

import std.net.http (Method)

Method.parse('GET') # => Option.Some(Method.Get)
Method.parse('FOO') # => Option.None

Instance methods

!=

Show source code
Hide source code
fn pub !=(other: ref Self) -> Bool {
  !(self == other)
}
fn pub !=(other: ref Self) -> Bool

Returns true if self and the given object are not equal to each other.

==

Show source code
Hide source code
fn pub ==(other: Method) -> Bool {
  method.eq(self, other)
}
fn pub ==(other: Method) -> Bool

Returns true if self and the given object are equal to each other.

This operator is used to perform structural equality. This means two objects residing in different memory locations may be considered equal, provided their structure is equal. For example, two different arrays may be considered to have structural equality if they contain the exact same values.

clone

Show source code
Hide source code
fn pub inline clone -> Self {
  self
}
fn pub inline clone -> Method

Creates a clone of self.

The returned value is an owned value that is the same type as the receiver of this method. For example, cloning a ref Array[Int] results in a Array[Int], not another ref Array[Int].

fmt

Show source code
Hide source code
fn pub fmt(formatter: mut Formatter) {
  method.format(formatter, self)
}
fn pub fmt(formatter: mut Formatter)

Formats self in a human-readable format for debugging purposes.

get?

Show source code
Hide source code
fn pub inline get? -> Bool {
  match self {
    case Get -> true
    case _ -> false
  }
}
fn pub inline get? -> Bool

Returns true if self is a Method.Get.

hash

Show source code
Hide source code
fn pub inline hash[H: mut + Hasher](hasher: mut H) {
  method.hash(hasher, self)
}
fn pub inline hash[H: mut + Hasher](hasher: mut H: mut)

Writes the hash for self into the given Hasher.

safe?

Show source code
Hide source code
fn pub inline safe? -> Bool {
  match self {
    case Get or Head or Options or Trace -> true
    case _ -> false
  }
}
fn pub inline safe? -> Bool

Returns true if self is a "safe" method (RFC 9110, section 9.2.1).

Examples

import std.net.http (Method)

Method.Get.safe? # => true
Method.Post.safe? # => false

to_string

Show source code
Hide source code
fn pub to_string -> String {
  method.to_string(self)
}
fn pub to_string -> String

Converts self to a String.

Implemented traits

std.clone.

Clone

impl Clone for Method
std.cmp.

Equal

impl Equal for Method
std.fmt.

Format

impl Format for Method
std.hash.

Hash

impl Hash for Method
std.string.

ToString

impl ToString for Method