cuelang.org/go@v0.13.0/pkg/tool/http/http.cue (about)

     1  // Copyright 2018 The CUE Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package http
    16  
    17  Get: Do & {method: "GET"}
    18  Post: Do & {method: "POST"}
    19  Put: Do & {method: "PUT"}
    20  Delete: Do & {method: "DELETE"}
    21  
    22  Do: {
    23  	$id: _id
    24  	_id: *"tool/http.Do" | "http" // http for backwards compatibility
    25  
    26  	method: string
    27  	url:    string // TODO: make url.URL type
    28  
    29  	// followRedirects controls whether the http client follows redirects
    30  	// or not. Defaults to true, like the default net/http client in Go.
    31  	followRedirects: *true | bool
    32  
    33  	tls: {
    34  		// Whether the server certificate must be validated.
    35  		verify: *true | bool
    36  		// PEM encoded certificate(s) to validate the server certificate.
    37  		// If not set the CA bundle of the system is used.
    38  		caCert?: bytes | string
    39  	}
    40  
    41  	request: {
    42  		body?: bytes | string
    43  		header: [string]: string | [...string]
    44  		trailer: [string]: string | [...string]
    45  	}
    46  	response: {
    47  		status:     string
    48  		statusCode: int
    49  
    50  		body: *bytes | string
    51  		header: [string]: string | [...string]
    52  		trailer: [string]: string | [...string]
    53  	}
    54  }
    55  
    56  //  TODO: support serving once we have the cue serve command.
    57  // Serve: {
    58  //  port: int
    59  //
    60  //  cert: string
    61  //  key:  string
    62  //
    63  //  handle: [Pattern=string]: Message & {
    64  //   pattern: Pattern
    65  //  }
    66  // }