/kodo/issues"> Issues 0 Pull Requests 0 Commits 882 Releases 0

26 Commits (3ae0f11c597d930f8e23489e5be8e3c489bd1d4e)

Author SHA1 Message Date
  Kimi.Huang 1552d2b18e Fix Bug: final_coupon_expire_at 7 years ago
  Kimi.Huang b8ba7d7473 final_coupon_expire_at 7 years ago
  Kimi.Huang 4c3166fc47 coupon_info 7 years ago
  Kimi.Huang ded4db2cda activityinfo_model_uni_names 7 years ago
  Brightcells ff3a23ccf0 Activity 7 years ago
  Brightcells 6e7c94e744 MchInfoDecryptLogInfo 8 years ago
  Brightcells 15e0f2277f MchInfoEncryptLogInfo 8 years ago
  Brightcells 5fdb5b42fd Logfile Upload 8 years ago
  Brightcells 537c495621 Statistic 8 years ago
  Brightcells 44a6cdf337 Statistic 8 years ago
  Brightcells d6f9edb0d2 model.model_full_name or model.model_name 8 years ago
  Brightcells 145973f8f0 Add brand_full_name for BrandInfo 8 years ago
  Brightcells 71993af1e4 Add integral for ModelInfo 8 years ago
  Brightcells 018d52f61d Update package django_xxx 8 years ago
  Brightcells 1796c9c28c Add cipherlen for ciphertext 8 years ago
  Brightcells a272ee8787 AttributeError: 'ModelInfo' object has no attribute 'model_imgs' 8 years ago
  Brightcells 2c88ab8d3e AttributeError: 'list' object has no attribute 'model_imgs' 8 years ago
  Brightcells 936cee4d66 Return encrypt goods info 8 years ago
  Brightcells 7f9088cde4 ID => PK 8 years ago
  Brightcells cfbab9ae47 Remove B64 8 years ago
  Brightcells f38d3bf980 Caesar Alg 8 years ago
  Brightcells 14faa83d54 Change plaintext format 8 years ago
  Brightcells 2181a06f23 Kodo update 8 years ago
  Brightcells bd794a93f4 logit for encrypt/decrypt 8 years ago
  Brightcells be7a80534a B64 only 8 years ago
  Brightcells aa31a5f59a Add kodo 8 years ago
adminSystem - Gogs: Go Git Service

Няма описание

FFIB: 11e3a9652a first преди 8 години
..
HISTORY.md 11e3a9652a first преди 8 години
LICENSE 11e3a9652a first преди 8 години
README.md 11e3a9652a first преди 8 години
index.js 11e3a9652a first преди 8 години
package.json 11e3a9652a first преди 8 години

README.md

accepts

NPM Version NPM Downloads Node.js Version Build Status Test Coverage

Higher level content negotiation based on negotiator. Extracted from koa for general use.

In addition to negotiator, it allows:

  • Allows types as an array or arguments list, ie (['text/html', 'application/json']) as well as ('text/html', 'application/json').
  • Allows type shorthands such as json.
  • Returns false when no types match
  • Treats non-existent headers as *

Installation

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install accepts

API

var accepts = require('accepts')

accepts(req)

Create a new Accepts object for the given req.

.charset(charsets)

Return the first accepted charset. If nothing in charsets is accepted, then false is returned.

.charsets()

Return the charsets that the request accepts, in the order of the client's preference (most preferred first).

.encoding(encodings)

Return the first accepted encoding. If nothing in encodings is accepted, then false is returned.

.encodings()

Return the encodings that the request accepts, in the order of the client's preference (most preferred first).

.language(languages)

Return the first accepted language. If nothing in languages is accepted, then false is returned.

.languages()

Return the languages that the request accepts, in the order of the client's preference (most preferred first).

.type(types)

Return the first accepted type (and it is returned as the same text as what appears in the types array). If nothing in types is accepted, then false is returned.

The types array can contain full MIME types or file extensions. Any value that is not a full MIME types is passed to require('mime-types').lookup.

.types()

Return the types that the request accepts, in the order of the client's preference (most preferred first).

Examples

Simple type negotiation

This simple example shows how to use accepts to return a different typed respond body based on what the client wants to accept. The server lists it's preferences in order and will get back the best match between the client and server.

var accepts = require('accepts')
var http = require('http')

function app (req, res) {
  var accept = accepts(req)

  // the order of this list is significant; should be server preferred order
  switch (accept.type(['json', 'html'])) {
    case 'json':
      res.setHeader('Content-Type', 'application/json')
      res.write('{"hello":"world!"}')
      break
    case 'html':
      res.setHeader('Content-Type', 'text/html')
      res.write('<b>hello, world!</b>')
      break
    default:
      // the fallback is text/plain, so no need to specify it above
      res.setHeader('Content-Type', 'text/plain')
      res.write('hello, world!')
      break
  }

  res.end()
}

http.createServer(app).listen(3000)

You can test this out with the cURL program:

curl -I -H'Accept: text/html' http://localhost:3000/

License

MIT