1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- Prism.languages.http = {
- 'request-line': {
- pattern: /^(POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b\shttps?:\/\/\S+\sHTTP\/[0-9.]+/,
- inside: {
- // HTTP Verb
- property: /^\b(POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b/,
- // Path or query argument
- 'attr-name': /:\w+/
- }
- },
- 'response-status': {
- pattern: /^HTTP\/1.[01] [0-9]+.*/,
- inside: {
- // Status, e.g. 200 OK
- property: /[0-9]+[A-Z\s-]+$/i
- }
- },
- // HTTP header name
- keyword: /^[\w-]+:(?=.+)/m
- };
- // Create a mapping of Content-Type headers to language definitions
- var httpLanguages = {
- 'application/json': Prism.languages.javascript,
- 'application/xml': Prism.languages.markup,
- 'text/xml': Prism.languages.markup,
- 'text/html': Prism.languages.markup
- };
- // Insert each content type parser that has its associated language
- // currently loaded.
- for (var contentType in httpLanguages) {
- if (httpLanguages[contentType]) {
- var options = {};
- options[contentType] = {
- pattern: new RegExp('(content-type:\\s*' + contentType + '[\\w\\W]*?)\\n\\n[\\w\\W]*', 'i'),
- lookbehind: true,
- inside: {
- rest: httpLanguages[contentType]
- }
- };
- Prism.languages.insertBefore('http', 'keyword', options);
- }
- }
|